mirror of
https://github.com/danog/ir.git
synced 2024-11-30 04:39:43 +01:00
Add LICENSE and copyright notices
This commit is contained in:
parent
2ff0617db6
commit
cc56f12f13
21
LICENSE
Normal file
21
LICENSE
Normal file
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2022 Zend by Perforce
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
@ -1,3 +1,12 @@
|
||||
/*
|
||||
* IR - Lightweight JIT Compilation Framework
|
||||
* (Folding engine generator)
|
||||
* Copyright (C) 2022 Zend by Perforce.
|
||||
* Authors: Dmitry Stogov <dmitry@php.net>
|
||||
*
|
||||
* Based on Mike Pall's implementation for LuaJIT.
|
||||
*/
|
||||
|
||||
#include "ir.h"
|
||||
#include <string.h>
|
||||
|
||||
|
@ -1,4 +1,10 @@
|
||||
<?php
|
||||
/*
|
||||
* IR - Lightweight JIT Compilation Framework
|
||||
* (Test driver)
|
||||
* Copyright (C) 2022 Zend by Perforce.
|
||||
* Authors: Dmitry Stogov <dmitry@php.net>
|
||||
*/
|
||||
|
||||
function parse_test($test, &$name, &$code, &$expect, &$args, &$target) {
|
||||
$text = @file_get_contents($test);
|
||||
|
16
ir.c
16
ir.c
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* IR - Lightweight JIT Compilation Framework
|
||||
* (IR construction, folding, utilities)
|
||||
* Copyright (C) 2022 Zend by Perforce.
|
||||
* Authors: Dmitry Stogov <dmitry@php.net>
|
||||
*
|
||||
* The logical IR representation is based on Cliff Click's Sea of Nodes.
|
||||
* See: C. Click, M. Paleczny. “A Simple Graph-Based Intermediate
|
||||
* Representation” In ACM SIGPLAN Workshop on Intermediate Representations
|
||||
* (IR '95), pages 35-49, Jan. 1995.
|
||||
*
|
||||
* The phisical IR representation is based on Mike Pall's LuaJIT IR.
|
||||
* See: M. Pall. “LuaJIT 2.0 intellectual property disclosure and research
|
||||
* opportunities” November 2009 http://lua-users.org/lists/lua-l/2009-11/msg00089.html
|
||||
*/
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
# define _GNU_SOURCE
|
||||
#endif
|
||||
|
23
ir.g
23
ir.g
@ -1,7 +1,12 @@
|
||||
/*
|
||||
To generate ir_load.c use llk <https://github.com/dstogov/llk>:
|
||||
php llk.php ir.g
|
||||
*/
|
||||
* IR - Lightweight JIT Compilation Framework
|
||||
* (IR loader)
|
||||
* Copyright (C) 2022 Zend by Perforce.
|
||||
* Authors: Dmitry Stogov <dmitry@php.net>
|
||||
*
|
||||
* To generate ir_load.c use llk <https://github.com/dstogov/llk>:
|
||||
* php llk.php ir.g
|
||||
*/
|
||||
|
||||
%start ir
|
||||
%case-sensetive true
|
||||
@ -11,7 +16,17 @@ php llk.php ir.g
|
||||
%indent "\t"
|
||||
|
||||
%{
|
||||
/* This file is generated from "ir.g". Do not edit! */
|
||||
/*
|
||||
* IR - Lightweight JIT Compilation Framework
|
||||
* (IR loader)
|
||||
* Copyright (C) 2005-2022 Zend by Perforce.
|
||||
* Authors: Dmitry Stogov <dmitry@php.net>
|
||||
*
|
||||
* This file is generated from "ir.g". Do not edit!
|
||||
*
|
||||
* To generate ir_load.c use llk <https://github.com/dstogov/llk>:
|
||||
* php llk.php ir.g
|
||||
*/
|
||||
|
||||
#include "ir.h"
|
||||
#include "ir_private.h"
|
||||
|
7
ir.h
7
ir.h
@ -1,3 +1,10 @@
|
||||
/*
|
||||
* IR - Lightweight JIT Compilation Framework
|
||||
* (Public API)
|
||||
* Copyright (C) 2022 Zend by Perforce.
|
||||
* Authors: Dmitry Stogov <dmitry@php.net>
|
||||
*/
|
||||
|
||||
#ifndef IR_H
|
||||
#define IR_H
|
||||
|
||||
|
@ -1,3 +1,10 @@
|
||||
/*
|
||||
* IR - Lightweight JIT Compilation Framework
|
||||
* (Aarch64 native code generator based on DynAsm)
|
||||
* Copyright (C) 2022 Zend by Perforce.
|
||||
* Authors: Dmitry Stogov <dmitry@php.net>
|
||||
*/
|
||||
|
||||
|.arch arm64
|
||||
|
||||
|.actionlist dasm_actions
|
||||
|
@ -1,3 +1,10 @@
|
||||
/*
|
||||
* IR - Lightweight JIT Compilation Framework
|
||||
* (Aarch64 CPU specific definitions)
|
||||
* Copyright (C) 2022 Zend by Perforce.
|
||||
* Authors: Dmitry Stogov <dmitry@php.net>
|
||||
*/
|
||||
|
||||
#ifndef IR_AARCH64_H
|
||||
#define IR_AARCH64_H
|
||||
|
||||
|
7
ir_cfg.c
7
ir_cfg.c
@ -1,3 +1,10 @@
|
||||
/*
|
||||
* IR - Lightweight JIT Compilation Framework
|
||||
* (CFG - Control Flow Graph)
|
||||
* Copyright (C) 2022 Zend by Perforce.
|
||||
* Authors: Dmitry Stogov <dmitry@php.net>
|
||||
*/
|
||||
|
||||
#include "ir.h"
|
||||
#include "ir_private.h"
|
||||
|
||||
|
@ -1,3 +1,10 @@
|
||||
/*
|
||||
* IR - Lightweight JIT Compilation Framework
|
||||
* (IR verification)
|
||||
* Copyright (C) 2022 Zend by Perforce.
|
||||
* Authors: Dmitry Stogov <dmitry@php.net>
|
||||
*/
|
||||
|
||||
#include "ir.h"
|
||||
#include "ir_private.h"
|
||||
|
||||
@ -35,7 +42,6 @@ void ir_consistency_check(void)
|
||||
|
||||
bool ir_check(ir_ctx *ctx)
|
||||
{
|
||||
//TODO:
|
||||
ir_ref i, j, n, *p, use;
|
||||
ir_insn *insn, *use_insn;
|
||||
uint32_t flags;
|
||||
|
@ -1,3 +1,10 @@
|
||||
/*
|
||||
* IR - Lightweight JIT Compilation Framework
|
||||
* (Disassembler based on libcapstone)
|
||||
* Copyright (C) 2022 Zend by Perforce.
|
||||
* Authors: Dmitry Stogov <dmitry@php.net>
|
||||
*/
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
# define _GNU_SOURCE
|
||||
#endif
|
||||
|
@ -1,3 +1,10 @@
|
||||
/*
|
||||
* IR - Lightweight JIT Compilation Framework
|
||||
* (debug dumps)
|
||||
* Copyright (C) 2022 Zend by Perforce.
|
||||
* Authors: Dmitry Stogov <dmitry@php.net>
|
||||
*/
|
||||
|
||||
#include "ir.h"
|
||||
#include "ir_private.h"
|
||||
|
||||
|
7
ir_elf.h
7
ir_elf.h
@ -1,3 +1,10 @@
|
||||
/*
|
||||
* IR - Lightweight JIT Compilation Framework
|
||||
* (ELF header definitions)
|
||||
* Copyright (C) 2022 Zend by Perforce.
|
||||
* Authors: Dmitry Stogov <dmitry@php.net>
|
||||
*/
|
||||
|
||||
#ifndef IR_ELF
|
||||
#define IR_ELF
|
||||
|
||||
|
@ -1,3 +1,10 @@
|
||||
/*
|
||||
* IR - Lightweight JIT Compilation Framework
|
||||
* (Native code generator based on DynAsm)
|
||||
* Copyright (C) 2022 Zend by Perforce.
|
||||
* Authors: Dmitry Stogov <dmitry@php.net>
|
||||
*/
|
||||
|
||||
#include "ir.h"
|
||||
|
||||
#if defined(IR_TARGET_X86) || defined(IR_TARGET_X64)
|
||||
|
@ -1,3 +1,10 @@
|
||||
/*
|
||||
* IR - Lightweight JIT Compilation Framework
|
||||
* (C code generator)
|
||||
* Copyright (C) 2022 Zend by Perforce.
|
||||
* Authors: Dmitry Stogov <dmitry@php.net>
|
||||
*/
|
||||
|
||||
#include "ir.h"
|
||||
#include "ir_private.h"
|
||||
|
||||
|
@ -1,3 +1,12 @@
|
||||
/*
|
||||
* IR - Lightweight JIT Compilation Framework
|
||||
* (Folding engine rules)
|
||||
* Copyright (C) 2022 Zend by Perforce.
|
||||
* Authors: Dmitry Stogov <dmitry@php.net>
|
||||
*
|
||||
* Based on Mike Pall's implementation for LuaJIT.
|
||||
*/
|
||||
|
||||
/* Constant Folding */
|
||||
IR_FOLD(EQ(C_BOOL, C_BOOL))
|
||||
IR_FOLD(EQ(C_U8, C_U8))
|
||||
|
14
ir_gcm.c
14
ir_gcm.c
@ -1,10 +1,16 @@
|
||||
/*
|
||||
* IR - Lightweight JIT Compilation Framework
|
||||
* (GCM - Global Code Motion and Scheduler)
|
||||
* Copyright (C) 2022 Zend by Perforce.
|
||||
* Authors: Dmitry Stogov <dmitry@php.net>
|
||||
*
|
||||
* The GCM algorithm is based on Cliff Click's publication
|
||||
* See: C. Click. "Global code motion, global value numbering" Submitted to PLDI‘95.
|
||||
*/
|
||||
|
||||
#include "ir.h"
|
||||
#include "ir_private.h"
|
||||
|
||||
/* GCM - Global Code Motion
|
||||
*
|
||||
* C. Click. "Global code motion, global value numbering" Submitted to PLDI ‘95.
|
||||
*/
|
||||
static void ir_gcm_schedule_early(ir_ctx *ctx, uint32_t *_blocks, ir_ref ref)
|
||||
{
|
||||
ir_ref j, n, *p;
|
||||
|
6
ir_gdb.c
6
ir_gdb.c
@ -1,6 +1,10 @@
|
||||
/*
|
||||
* IR - Lightweight JIT Compilation Framework
|
||||
* (GDB interface)
|
||||
* Copyright (C) 2022 Zend by Perforce.
|
||||
* Authors: Dmitry Stogov <dmitry@php.net>
|
||||
*
|
||||
* Based on Mike Pall's implementation of GDB interface for LuaJIT.
|
||||
* LuaJIT -- a Just-In-Time Compiler for Lua. http://luajit.org/
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
|
12
ir_load.c
12
ir_load.c
@ -1,4 +1,14 @@
|
||||
/* This file is generated from "ir.g". Do not edit! */
|
||||
/*
|
||||
* IR - Lightweight JIT Compilation Framework
|
||||
* (IR loader)
|
||||
* Copyright (C) 2005-2022 Zend by Perforce.
|
||||
* Authors: Dmitry Stogov <dmitry@php.net>
|
||||
*
|
||||
* This file is generated from "ir.g". Do not edit!
|
||||
*
|
||||
* To generate ir_load.c use llk <https://github.com/dstogov/llk>:
|
||||
* php llk.php ir.g
|
||||
*/
|
||||
|
||||
#include "ir.h"
|
||||
#include "ir_private.h"
|
||||
|
@ -1,3 +1,10 @@
|
||||
/*
|
||||
* IR - Lightweight JIT Compilation Framework
|
||||
* (IR CLI driver)
|
||||
* Copyright (C) 2022 Zend by Perforce.
|
||||
* Authors: Dmitry Stogov <dmitry@php.net>
|
||||
*/
|
||||
|
||||
#include "ir.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
10
ir_patch.c
10
ir_patch.c
@ -1,8 +1,16 @@
|
||||
/*
|
||||
* IR - Lightweight JIT Compilation Framework
|
||||
* (Native code patcher)
|
||||
* Copyright (C) 2022 Zend by Perforce.
|
||||
* Authors: Dmitry Stogov <dmitry@php.net>
|
||||
*
|
||||
* Based on Mike Pall's implementation for LuaJIT.
|
||||
*/
|
||||
|
||||
#include "ir.h"
|
||||
#include "ir_private.h"
|
||||
|
||||
#if defined(IR_TARGET_X86) || defined(IR_TARGET_X64)
|
||||
/* This taken from LuaJIT. Thanks to Mike Pall. */
|
||||
static uint32_t _asm_x86_inslen(const uint8_t* p)
|
||||
{
|
||||
static const uint8_t map_op1[256] = {
|
||||
|
30
ir_perf.c
30
ir_perf.c
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* IR - Lightweight JIT Compilation Framework
|
||||
* (Linux perf interface)
|
||||
* Copyright (C) 2022 Zend by Perforce.
|
||||
* Authors: Dmitry Stogov <dmitry@php.net>
|
||||
*
|
||||
* 1) Profile using perf-<pid>.map
|
||||
* perf record ./prog
|
||||
* perf report
|
||||
*
|
||||
* 2) Profile using jit-<pid>.dump
|
||||
* perf record -k 1 ./prog
|
||||
* perf inject -j -i perf.data -o perf.data.jitted
|
||||
* perf report -i perf.data.jitted
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <time.h>
|
||||
@ -29,20 +45,6 @@ extern unsigned int thr_self(void);
|
||||
#include "ir.h"
|
||||
#include "ir_elf.h"
|
||||
|
||||
/*
|
||||
* 1) Profile using perf-<pid>.map
|
||||
*
|
||||
* perf record ./prog
|
||||
* perf report
|
||||
*
|
||||
* 2) Profile using jit-<pid>.dump
|
||||
*
|
||||
* perf record -k 1 ./prog
|
||||
* perf inject -j -i perf.data -o perf.data.jitted
|
||||
* perf report -i perf.data.jitted
|
||||
*
|
||||
*/
|
||||
|
||||
#define IR_PERF_JITDUMP_HEADER_MAGIC 0x4A695444
|
||||
#define IR_PERF_JITDUMP_HEADER_VERSION 1
|
||||
|
||||
|
7
ir_php.h
7
ir_php.h
@ -1,3 +1,10 @@
|
||||
/*
|
||||
* IR - Lightweight JIT Compilation Framework
|
||||
* (IR/PHP integration)
|
||||
* Copyright (C) 2022 Zend by Perforce.
|
||||
* Authors: Dmitry Stogov <dmitry@php.net>
|
||||
*/
|
||||
|
||||
#ifndef IR_PHP_H
|
||||
#define IR_PHP_H
|
||||
|
||||
|
@ -1,3 +1,10 @@
|
||||
/*
|
||||
* IR - Lightweight JIT Compilation Framework
|
||||
* (Common data structures and non public definitions)
|
||||
* Copyright (C) 2022 Zend by Perforce.
|
||||
* Authors: Dmitry Stogov <dmitry@php.net>
|
||||
*/
|
||||
|
||||
#ifndef IR_PRIVATE_H
|
||||
#define IR_PRIVATE_H
|
||||
#include <string.h>
|
||||
|
28
ir_ra.c
28
ir_ra.c
@ -1,3 +1,15 @@
|
||||
/*
|
||||
* IR - Lightweight JIT Compilation Framework
|
||||
* (RA - Register Allocation, Liveness, Coalescing, SSA Deconstruction)
|
||||
* Copyright (C) 2022 Zend by Perforce.
|
||||
* Authors: Dmitry Stogov <dmitry@php.net>
|
||||
*
|
||||
* See: "Linear Scan Register Allocation on SSA Form", Christian Wimmer and
|
||||
* Michael Franz, CGO'10 (2010)
|
||||
* See: "Optimized Interval Splitting in a Linear Scan Register Allocator",
|
||||
* Christian Wimmer VEE'10 (2005)
|
||||
*/
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
# define _GNU_SOURCE
|
||||
#endif
|
||||
@ -34,8 +46,6 @@ bool ir_reg_is_int(int32_t reg)
|
||||
return reg >= IR_REG_GP_FIRST && reg <= IR_REG_GP_LAST;
|
||||
}
|
||||
|
||||
/* RA - Register Allocation, Liveness, Coalescing and SSA Resolution */
|
||||
|
||||
int ir_assign_virtual_registers(ir_ctx *ctx)
|
||||
{
|
||||
uint32_t *vregs;
|
||||
@ -79,11 +89,8 @@ int ir_assign_virtual_registers(ir_ctx *ctx)
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Lifetime intervals construction
|
||||
*
|
||||
* See "Linear Scan Register Allocation on SSA Form", Christian Wimmer and
|
||||
* Michael Franz, CGO'10 (2010), Figure 4.
|
||||
*/
|
||||
/* Lifetime intervals construction */
|
||||
|
||||
static void ir_add_local_var(ir_ctx *ctx, int v, uint8_t type)
|
||||
{
|
||||
ir_live_interval *ival = ctx->live_intervals[v];
|
||||
@ -1220,11 +1227,8 @@ int ir_gen_dessa_moves(ir_ctx *ctx, int b, emit_copy_t emit_copy)
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Linear Scan Register Allocation
|
||||
*
|
||||
* See "Optimized Interval Splitting in a Linear Scan Register Allocator",
|
||||
* Christian Wimmer VEE'10 (2005), Figure 2.
|
||||
*/
|
||||
/* Linear Scan Register Allocation */
|
||||
|
||||
#ifdef IR_DEBUG
|
||||
# define IR_LOG_LSRA(action, ival, comment) do { \
|
||||
if (ctx->flags & IR_DEBUG_RA) { \
|
||||
|
@ -1,3 +1,10 @@
|
||||
/*
|
||||
* IR - Lightweight JIT Compilation Framework
|
||||
* (IR saver)
|
||||
* Copyright (C) 2022 Zend by Perforce.
|
||||
* Authors: Dmitry Stogov <dmitry@php.net>
|
||||
*/
|
||||
|
||||
#include "ir.h"
|
||||
#include "ir_private.h"
|
||||
|
||||
|
17
ir_sccp.c
17
ir_sccp.c
@ -1,3 +1,14 @@
|
||||
/*
|
||||
* IR - Lightweight JIT Compilation Framework
|
||||
* (SCCP - Sparse Conditional Constant Propagation)
|
||||
* Copyright (C) 2022 Zend by Perforce.
|
||||
* Authors: Dmitry Stogov <dmitry@php.net>
|
||||
*
|
||||
* The SCCP algorithm is based on M. N. Wegman and F. K. Zadeck publication
|
||||
* See: M. N. Wegman and F. K. Zadeck. "Constant propagation with conditional branches"
|
||||
* ACM Transactions on Programming Languages and Systems, 13(2):181-210, April 1991
|
||||
*/
|
||||
|
||||
#include "ir.h"
|
||||
#include "ir_private.h"
|
||||
|
||||
@ -5,12 +16,6 @@
|
||||
# pragma GCC diagnostic ignored "-Warray-bounds"
|
||||
#endif
|
||||
|
||||
/* SCCP - Sparse Conditional Constant Propagation + Copy Propagation
|
||||
*
|
||||
* M. N. Wegman and F. K. Zadeck. "Constant propagation with conditional branches"
|
||||
* ACM Transactions on Programming Languages and Systems, 13(2):181-210, April 1991
|
||||
*/
|
||||
|
||||
#define IR_TOP IR_UNUSED
|
||||
#define IR_BOTTOM IR_LAST_OP
|
||||
|
||||
|
@ -1,3 +1,10 @@
|
||||
/*
|
||||
* IR - Lightweight JIT Compilation Framework
|
||||
* (String table)
|
||||
* Copyright (C) 2022 Zend by Perforce.
|
||||
* Authors: Dmitry Stogov <dmitry@php.net>
|
||||
*/
|
||||
|
||||
#include "ir.h"
|
||||
#include "ir_private.h"
|
||||
|
||||
|
@ -1,3 +1,10 @@
|
||||
/*
|
||||
* IR - Lightweight JIT Compilation Framework
|
||||
* (Mandelbrot example)
|
||||
* Copyright (C) 2022 Zend by Perforce.
|
||||
* Authors: Dmitry Stogov <dmitry@php.net>
|
||||
*/
|
||||
|
||||
#include "ir.h"
|
||||
#include <sys/time.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -1,3 +1,10 @@
|
||||
/*
|
||||
* IR - Lightweight JIT Compilation Framework
|
||||
* (x86/x86_64 native code generator based on DynAsm)
|
||||
* Copyright (C) 2022 Zend by Perforce.
|
||||
* Authors: Dmitry Stogov <dmitry@php.net>
|
||||
*/
|
||||
|
||||
|.if X64
|
||||
|.arch x64
|
||||
|.else
|
||||
|
Loading…
Reference in New Issue
Block a user