├── opt ├── ir_regmdssa.h ├── md.h ├── Makefile.ip.inc ├── Makefile.ref_targmach_info.inc ├── irc_attr_ext.inc ├── pass_type_ext.inc ├── dbg_lang_ext.inc ├── ir_high_opt.h ├── ir_middle_opt.h ├── targ_opt.inc ├── targ_desc_ext.impl ├── targ_code_ext.inc ├── targ_irc_attr_ext.inc ├── targ_pass_type_ext.inc ├── targ_dbg_lang_ext.inc ├── goto_opt.h ├── goto_opt.cpp ├── targ_decl_ext.h ├── const.h ├── targ_utils_ext.h ├── ir_ext.cpp ├── ir_verify_ext.h ├── cfg.cpp ├── status.cpp ├── status.h ├── commoninc.h ├── ir_dump_ext.h ├── targ_const_info.h ├── storage_space.cpp ├── lt_prio_mgr.h ├── storage_space.h └── extend_type.cpp ├── Makefile.xoc.inc ├── com ├── build.sh ├── lpsol.h ├── linsys.h ├── linsys.cpp ├── sgraph.cpp ├── example │ ├── README.txt │ ├── build.sh │ ├── use_vector.cpp │ ├── use_tmap.cpp │ ├── use_bs.cpp │ ├── use_list.cpp │ └── use_ttab.cpp ├── Makefile.inc ├── README.txt ├── benchmark │ └── README.txt ├── xcominc.h ├── xtensor.cpp ├── ltype.cpp ├── sbs.cpp ├── numdiff.cpp ├── allocator.h ├── log.h └── Makefile.option ├── elf ├── example │ ├── clean.sh │ ├── build.sh │ ├── README.txt │ └── readelf.prj │ │ └── readelf.prj.sln ├── Makefile.inc ├── README.txt ├── ph_type_ext.inc ├── sect_type_ext.inc ├── targ_ph_type_ext.inc ├── targ_sect_type_ext.inc ├── targ_sect_desc_ext.impl ├── sect_desc_ext.impl ├── elfinc.h └── elf_targinfo.h ├── doc └── Manual.txt ├── reader ├── Makefile.inc ├── xcode_ext.inc ├── xcodeinfo_ext.impl ├── targ_xcode_ext.inc ├── targ_xcodeinfo_ext.impl └── reader.h ├── example ├── ex1 │ ├── README.txt │ ├── Makefile │ └── ex1 │ │ └── ex1.sln └── grreader │ ├── build.bat │ ├── README.txt │ ├── input.gr │ ├── Makefile │ └── grreader.sln ├── .gitignore ├── mach ├── Makefile.inc ├── machoption.cpp ├── machoption.h └── machinc.h ├── dex ├── Makefile.opt.ext.inc ├── clibs │ └── basic │ │ ├── include │ │ ├── utils │ │ │ ├── ccrc32.h │ │ │ ├── cbuf.h │ │ │ ├── clbe.h │ │ │ ├── cbytestream.h │ │ │ └── chashtable.h │ │ ├── config │ │ │ ├── clibconfig_unix.h │ │ │ ├── clibconfig_brew.h │ │ │ ├── clibconfig_iphone.h │ │ │ ├── clibconfig_android.h │ │ │ ├── clibconfig_wince.h │ │ │ ├── clibconfig_win32.h │ │ │ ├── clibconfig_mtk.h │ │ │ └── clibconfig_symbian.h │ │ ├── dl │ │ │ └── cdlfcn.h │ │ ├── zip │ │ │ └── cziputils.h │ │ ├── thread │ │ │ └── cthread.h │ │ ├── trace │ │ │ └── ctrace.h │ │ ├── utf │ │ │ └── cutf.h │ │ ├── clibconfig.h │ │ ├── mem │ │ │ └── cmem.h │ │ ├── sys │ │ │ └── csys.h │ │ └── str │ │ │ └── cstr.h │ │ └── arch │ │ ├── common │ │ ├── str │ │ │ └── cstrport.h │ │ ├── errno │ │ │ └── cerrno.c │ │ ├── sys │ │ │ ├── cmainport.h │ │ │ ├── csysport.h │ │ │ └── csys.c │ │ ├── trace │ │ │ └── ctraceport.h │ │ ├── thread │ │ │ ├── cthread.c │ │ │ └── cthreadport.h │ │ ├── zip │ │ │ └── czipport.h │ │ ├── time │ │ │ └── ctimeport.h │ │ ├── mem │ │ │ ├── cmemport.h │ │ │ └── cmem.c │ │ └── utils │ │ │ └── clbe.c │ │ ├── android │ │ ├── math │ │ │ └── cmathport.c │ │ ├── dl │ │ │ └── cdlfcn.c │ │ ├── trace │ │ │ └── ctraceport.c │ │ ├── sys │ │ │ └── csysport.c │ │ ├── time │ │ │ └── ctimeport.c │ │ ├── thread │ │ │ └── cthreadport.c │ │ ├── zip │ │ │ └── czipport.c │ │ └── mem │ │ │ └── cmemport.c │ │ ├── unix │ │ ├── math │ │ │ └── cmathport.c │ │ ├── trace │ │ │ └── ctraceport.c │ │ ├── time │ │ │ └── ctimeport.c │ │ ├── zip │ │ │ └── czipport.c │ │ └── mem │ │ │ └── cmemport.c │ │ └── windows │ │ ├── math │ │ └── cmathport.c │ │ ├── dl │ │ └── cdlfcn.c │ │ ├── trace │ │ └── ctraceport.c │ │ ├── time │ │ └── ctimeport.c │ │ ├── zip │ │ └── czipport.c │ │ └── mem │ │ └── cmemport.c ├── README.txt ├── include │ ├── aot.h │ └── xassert.h ├── linealloc │ └── drAlloc.h ├── dex_hook.h ├── lir │ └── drcode.h ├── dex2dex │ ├── d2d_dexlib.h │ ├── cmdline.h │ └── d2d_comm.h ├── dex_pass_mgr.h ├── dex_driver.h └── dex_cp.h ├── Roadmap.txt ├── AUTHORS.txt ├── arm ├── arm_sect_desc_ext.impl ├── arm_sect_type_ext.inc ├── arm_opt.inc ├── arm_irc_attr_ext.inc ├── arm_pass_type_ext.inc └── arm_code_ext.inc ├── x64 └── x64.h ├── score └── score.h ├── LICENSE.txt ├── README.md └── win └── misc.h /opt/ir_regmdssa.h: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Makefile.xoc.inc: -------------------------------------------------------------------------------- 1 | XOC_OUTPUT = libxoc.a 2 | -------------------------------------------------------------------------------- /com/build.sh: -------------------------------------------------------------------------------- 1 | make clean 2 | make all 3 | 4 | -------------------------------------------------------------------------------- /elf/example/clean.sh: -------------------------------------------------------------------------------- 1 | make clean -f Makefile.readelf 2 | -------------------------------------------------------------------------------- /opt/md.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stevenknown/xoc/HEAD/opt/md.h -------------------------------------------------------------------------------- /com/lpsol.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stevenknown/xoc/HEAD/com/lpsol.h -------------------------------------------------------------------------------- /com/linsys.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stevenknown/xoc/HEAD/com/linsys.h -------------------------------------------------------------------------------- /com/linsys.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stevenknown/xoc/HEAD/com/linsys.cpp -------------------------------------------------------------------------------- /com/sgraph.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stevenknown/xoc/HEAD/com/sgraph.cpp -------------------------------------------------------------------------------- /doc/Manual.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stevenknown/xoc/HEAD/doc/Manual.txt -------------------------------------------------------------------------------- /reader/Makefile.inc: -------------------------------------------------------------------------------- 1 | READER_OBJS+=\ 2 | ir_lex.o\ 3 | ir_parser.o\ 4 | grreader.o 5 | -------------------------------------------------------------------------------- /example/ex1/README.txt: -------------------------------------------------------------------------------- 1 | You could compile xoc source files with your project or use the libxoc.a 2 | -------------------------------------------------------------------------------- /opt/Makefile.ip.inc: -------------------------------------------------------------------------------- 1 | $(info "CONDBR:opt/Makefile.inc:FOR_IP=$(FOR_IP)") 2 | OPT_OBJS+=\ 3 | ir_vrp.o\ 4 | ir_dse.o\ 5 | ir_vect.o\ 6 | derivative.o\ 7 | var2offset.o 8 | -------------------------------------------------------------------------------- /example/grreader/build.bat: -------------------------------------------------------------------------------- 1 | @rem Build project by Visual Studio 2 | "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\devenv.com" /build Debug grreader.sln 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.d 2 | *.o 3 | *.a 4 | *.exe 5 | *.log 6 | mi.test.elf 7 | 8 | *.gcno 9 | *.gcda 10 | *.gcov 11 | 12 | report 13 | tools/incre_report 14 | tools/gcovr.log 15 | tools/gcovr_incre.log 16 | -------------------------------------------------------------------------------- /mach/Makefile.inc: -------------------------------------------------------------------------------- 1 | MACH_OBJS+=\ 2 | ir2minst.o\ 3 | machoption.o\ 4 | migen.o\ 5 | minst.o\ 6 | minst_desc.o\ 7 | minst_field.o\ 8 | minst_mgr.o\ 9 | mi_reloc_mgr.o 10 | 11 | CFLAGS+=-Wno-unknown-pragmas 12 | -------------------------------------------------------------------------------- /elf/Makefile.inc: -------------------------------------------------------------------------------- 1 | ELF_OBJS+=\ 2 | elf_mgr.o\ 3 | elf_header.o\ 4 | elf_targinfo.o\ 5 | elf_option.o \ 6 | linker_mgr.o\ 7 | linker_pass_mgr.o\ 8 | cache_miss.o\ 9 | linker_relax.o 10 | 11 | CFLAGS+=-Wno-unknown-pragmas 12 | -------------------------------------------------------------------------------- /dex/Makefile.opt.ext.inc: -------------------------------------------------------------------------------- 1 | $(info "CONDBR:dex/Makefile.opt.ext.inc:TARG=$(TARG),TARG_DIR=$(TARG_DIR)") 2 | OPT_OBJS+=\ 3 | lsra_impl.o\ 4 | lsra_scan_in_pos.o\ 5 | lsra_scan_in_prio.o\ 6 | lifetime.o\ 7 | targinfo_mgr.o\ 8 | linear_scan.o 9 | -------------------------------------------------------------------------------- /com/example/README.txt: -------------------------------------------------------------------------------- 1 | Build and run all examples: 2 | ./build.sh 3 | 4 | If you are building testbs.cpp, the macro -D_LINUX_ is needed. 5 | e.g: g++ -std=c++0x testbs.cpp ../smempool.cpp ../bs.cpp -I.. \ 6 | -D_LINUX_ -lstdc++ 7 | -------------------------------------------------------------------------------- /example/grreader/README.txt: -------------------------------------------------------------------------------- 1 | You could compile xoc source files with your project or use the libxoc.a 2 | 3 | Windows: 4 | 1. build.bat 5 | 2. x64/Debug/grreader.exe 6 | 7 | Linux: 8 | make 9 | ./grreader.exe 10 | -------------------------------------------------------------------------------- /dex/clibs/basic/include/utils/ccrc32.h: -------------------------------------------------------------------------------- 1 | /*Copyright 2011 Alibaba Group*/ 2 | #ifndef CLIBS_CRC32_H 3 | #define CLIBS_CRC32_H 4 | 5 | #include "std/cstd.h" 6 | 7 | EXTERN_C UInt32 ccrc32(BYTE* message, UInt32 msgsize, UInt32 crc); 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /example/grreader/input.gr: -------------------------------------------------------------------------------- 1 | region program "program" () { 2 | var foo:any:(readonly, func, align(4)); 3 | region func main (var retbuf:mc<128>:(align(4))) { 4 | call:(readonly) $ret:i128 = foo(); 5 | return $ret; 6 | }; 7 | } 8 | -------------------------------------------------------------------------------- /dex/README.txt: -------------------------------------------------------------------------------- 1 | * How to add XOC module into Android ? 2 | Add two modules into Android to compile XOC and Clibs. 3 | xoc/dex/clibs/Android.mk 4 | xoc/dex/Android.mk 5 | The output libraries are libaoc_xoc.so and libaoc_clibs.so 6 | 7 | 8 | -------------------------------------------------------------------------------- /Roadmap.txt: -------------------------------------------------------------------------------- 1 | 2016 - 2017 2 | *. Correctness. 3 | *. New analysis module: Induction Variable Recognization 4 | *. SSA-back translation for exception block. 5 | *. Complete and refine test environment. 6 | *. Enable a new code generation module for arm, x86 target. 7 | -------------------------------------------------------------------------------- /dex/clibs/basic/include/config/clibconfig_unix.h: -------------------------------------------------------------------------------- 1 | /*Copyright 2011 Alibaba Group*/ 2 | #ifndef CLIBS_CONFIG_UNIX_H 3 | #define CLIBS_CONFIG_UNIX_H 4 | 5 | #define C_BYTE_ORDER C_LITTLE_ENDIAN 6 | 7 | #ifdef _DEBUG 8 | #define C_MAX_TRACE_SIZE (10*1024) 9 | #endif 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /dex/clibs/basic/arch/common/str/cstrport.h: -------------------------------------------------------------------------------- 1 | /*Copyright 2011 Alibaba Group*/ 2 | /* 3 | * cstrport.h 4 | * 5 | * Created on: Apr 19, 2009 6 | * Author: misa 7 | */ 8 | 9 | #ifndef CLIBS_STR_PORT_H 10 | #define CLIBS_STR_PORT_H 11 | 12 | #include "str/cstr.h" 13 | 14 | 15 | #endif /* CSTRPORT_H_ */ 16 | -------------------------------------------------------------------------------- /dex/clibs/basic/include/config/clibconfig_brew.h: -------------------------------------------------------------------------------- 1 | /*Copyright 2011 Alibaba Group*/ 2 | #ifndef CLIBS_CONFIG_BREW_H 3 | #define CLIBS_CONFIG_BREW_H 4 | 5 | #define C_BYTE_ORDER C_LITTLE_ENDIAN 6 | 7 | #define USE_SYSTEM_FONT 8 | 9 | #if 1 10 | #define C_MAX_TRACE_SIZE (10*1024) 11 | #endif 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /dex/clibs/basic/arch/common/errno/cerrno.c: -------------------------------------------------------------------------------- 1 | /*Copyright 2011 Alibaba Group*/ 2 | /* 3 | * cerrno.c 4 | * madagascar 5 | * 6 | * Created by Misa.Z on 2/19/09. 7 | * Copyright 2009 Virtualnology. All rights reserved. 8 | * 9 | */ 10 | 11 | #include "errno/cerrno.h" 12 | 13 | Int32 _cerrno = ERROR_NOTHING; 14 | -------------------------------------------------------------------------------- /dex/clibs/basic/include/config/clibconfig_iphone.h: -------------------------------------------------------------------------------- 1 | /*Copyright 2011 Alibaba Group*/ 2 | #ifndef CLIBS_CONFIG_UNIX_H 3 | #define CLIBS_CONFIG_UNIX_H 4 | 5 | #define C_BYTE_ORDER C_LITTLE_ENDIAN 6 | 7 | //#define USE_SYSTEM_CANVAS 8 | //#define USE_SYSTEM_FONT 9 | 10 | #if 1//def _DEBUG 11 | #define C_MAX_TRACE_SIZE (10*1024) 12 | #endif 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /dex/clibs/basic/include/dl/cdlfcn.h: -------------------------------------------------------------------------------- 1 | /*Copyright 2011 Alibaba Group*/ 2 | #ifndef CLIBS_DL_FUNC_H 3 | #define CLIBS_DL_FUNC_H 4 | 5 | #include "std/cstd.h" 6 | 7 | EXTERN_C ULong cdlopen(const char* name); 8 | 9 | EXTERN_C void cdlclose(ULong handle); 10 | 11 | EXTERN_C void* cdlsym(ULong handle, const char* symname); 12 | 13 | EXTERN_C const char* cdlerror(); 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /dex/clibs/basic/include/zip/cziputils.h: -------------------------------------------------------------------------------- 1 | /*Copyright 2011 Alibaba Group*/ 2 | #ifndef C_ZIP_UTILS_H 3 | #define C_ZIP_UTILS_H 4 | 5 | #include "zip/czip.h" 6 | 7 | EXTERN_C bool cZipUnpack(ZipHandle zip, const char* path); 8 | 9 | EXTERN_C bool cZipUnpackFile(const char* zipFname, const char* targetPath); 10 | 11 | EXTERN_C bool cZipPackDir(const char* zipFname, const char* aSrcPath); 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /dex/clibs/basic/arch/android/math/cmathport.c: -------------------------------------------------------------------------------- 1 | /*Copyright 2011 Alibaba Group*/ 2 | /* 3 | * cmathport.c 4 | * iplug.iphone 5 | * 6 | * Created by Misa.Z on 3/31/10. 7 | * Copyright 2010 VMKid. All rights reserved. 8 | * 9 | */ 10 | 11 | #include 12 | #include "std/cstd.h" 13 | 14 | Int32 cRandPort() { 15 | return rand(); 16 | } 17 | 18 | void cSRandPort(UInt32 seed) { 19 | srand(seed); 20 | } 21 | -------------------------------------------------------------------------------- /dex/clibs/basic/arch/unix/math/cmathport.c: -------------------------------------------------------------------------------- 1 | /*Copyright 2011 Alibaba Group*/ 2 | /* 3 | * cmathport.c 4 | * iplug.iphone 5 | * 6 | * Created by Misa.Z on 3/31/10. 7 | * Copyright 2010 VMKid. All rights reserved. 8 | * 9 | */ 10 | 11 | #include 12 | #include "std/cstd.h" 13 | 14 | Int32 cRandPort() { 15 | return rand(); 16 | } 17 | 18 | void cSRandPort(UInt32 seed) { 19 | srand(seed); 20 | } 21 | -------------------------------------------------------------------------------- /dex/clibs/basic/include/config/clibconfig_android.h: -------------------------------------------------------------------------------- 1 | /*Copyright 2011 Alibaba Group*/ 2 | #ifndef CLIBS_CONFIG_ANDROID_H 3 | #define CLIBS_CONFIG_ANDROID_H 4 | 5 | #define C_BYTE_ORDER C_LITTLE_ENDIAN 6 | 7 | #ifdef _DEBUG 8 | #define MADA_DEBUG 9 | #define C_MAX_TRACE_SIZE (10*1024) 10 | #endif 11 | 12 | #define MADA_LINE_SEPERATOR "\n" 13 | 14 | #define CONFIG_PLATFORM_FILENAME "platform_unix.config" 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /elf/README.txt: -------------------------------------------------------------------------------- 1 | ELF Reader And Writer 2 | ============== 3 | 4 | The directory contain a module to read ELF information and write information into ELF binary file. 5 | This module requires other standard libraries that located in xcom. 6 | 7 | There is a demo under the example directory to show how to use the module. 8 | The demo is actually the readelf.exe and I believe it is very useful to help you integrate the module into your project. 9 | -------------------------------------------------------------------------------- /dex/clibs/basic/arch/windows/math/cmathport.c: -------------------------------------------------------------------------------- 1 | /*Copyright 2011 Alibaba Group*/ 2 | /* 3 | * cmathport.c 4 | * iplug.iphone 5 | * 6 | * Created by Misa.Z on 3/31/10. 7 | * Copyright 2010 VMKid. All rights reserved. 8 | * 9 | */ 10 | 11 | #include "math/cmathport.h" 12 | #include 13 | #include "std/cstd.h" 14 | 15 | Int32 cRandPort() { 16 | return rand(); 17 | } 18 | 19 | void cSRandPort(UInt32 seed) { 20 | srand(seed); 21 | } 22 | -------------------------------------------------------------------------------- /dex/clibs/basic/arch/android/dl/cdlfcn.c: -------------------------------------------------------------------------------- 1 | /*Copyright 2011 Alibaba Group*/ 2 | #include "dl/cdlfcn.h" 3 | #include 4 | 5 | ULong cdlopen(const char* name) { 6 | return (ULong)dlopen(name, RTLD_LAZY); 7 | } 8 | 9 | void cdlclose(ULong handle) { 10 | dlclose((void*)handle); 11 | } 12 | 13 | void* cdlsym(ULong handle, const char* symname) { 14 | return dlsym((void*)handle, symname); 15 | } 16 | 17 | const char* cdlerror() { 18 | return dlerror(); 19 | } 20 | -------------------------------------------------------------------------------- /AUTHORS.txt: -------------------------------------------------------------------------------- 1 | The file lists people who have have contributed to XOC project. 2 | If you have contributed a patch or made some other contribution to XOC, 3 | please submit a patch to this file to add yourself, and it will be done! 4 | 5 | Su Zhenyu, steven.known@gmail.com, primary architect of XOC 6 | GongKai, gong_k@126.com, 7 | JinYue, fionaking930@gmail.com, 8 | Guo XiaoXin, guonic@gmail.com, 9 | Zhang Ji Peng, 10 | Leslie Zhai, 11 | Yue Yang, 12 | Alex Cameron, 13 | -------------------------------------------------------------------------------- /com/Makefile.inc: -------------------------------------------------------------------------------- 1 | #DO NOT ADD VAR BEFORE FILES 2 | 3 | COM_OBJS+=\ 4 | ltype.o\ 5 | xmat.o\ 6 | comf.o\ 7 | strbuf.o\ 8 | smempool.o\ 9 | agraph.o\ 10 | sgraph.o\ 11 | rational.o\ 12 | birational.o\ 13 | bigint.o\ 14 | flty.o\ 15 | linsys.o\ 16 | bs.o\ 17 | log.o\ 18 | numdiff.o\ 19 | scc.o\ 20 | sbs.o\ 21 | sort.o\ 22 | byteop.o\ 23 | rpo.o\ 24 | tree.o\ 25 | domtree.o\ 26 | lca.o\ 27 | assemblebin.o\ 28 | fileobj.o\ 29 | xtensor.o\ 30 | diagnostic.o 31 | 32 | COM_OUTPUT=libxcom.a 33 | -------------------------------------------------------------------------------- /dex/clibs/basic/arch/common/sys/cmainport.h: -------------------------------------------------------------------------------- 1 | /*Copyright 2011 Alibaba Group*/ 2 | /* 3 | * cmainport.h 4 | * madagascar 5 | * 6 | * Created by Misa.Z on 2/19/09. 7 | * Copyright 2009 Virtualnology. All rights reserved. 8 | * 9 | */ 10 | 11 | #ifndef CLIBS_MAIN_H 12 | #define CLIBS_MAIN_H 13 | 14 | //this function didn't be implemented in arch source folder, that means you should implement it in your application's source !! 15 | extern int cMain(int argc, char** argv); 16 | 17 | #endif 18 | 19 | -------------------------------------------------------------------------------- /elf/example/build.sh: -------------------------------------------------------------------------------- 1 | IS_DEBUG=true 2 | OPEN_COVERAGE=false 3 | while [ "$#" -gt 0 ] 4 | do 5 | if [ $1 == "--release" ] 6 | then 7 | IS_DEBUG=false 8 | elif [ $1 == "--coverage" ] 9 | then 10 | OPEN_COVERAGE=true 11 | fi 12 | shift 13 | done 14 | 15 | make readelf.exe -f Makefile.readelf DEBUG=$IS_DEBUG FOR_ARM=false FOR_X86=false \ 16 | FOR_X64=false FOR_SCORE=false FOR_DEX=false FOR_JS=false \ 17 | TARG=FOR_ARM TARG_DIR=../../arm OPEN_COVERAGE=$OPEN_COVERAGE 18 | -------------------------------------------------------------------------------- /dex/clibs/basic/arch/common/trace/ctraceport.h: -------------------------------------------------------------------------------- 1 | /*Copyright 2011 Alibaba Group*/ 2 | /* 3 | * ctraceport.h 4 | * madagascar 5 | * 6 | * Created by Misa.Z on 2/19/09. 7 | * Copyright 2009 Virtualnology. All rights reserved. 8 | * 9 | */ 10 | 11 | #ifndef CLIBS_TRACE_PORT_H 12 | #define CLIBS_TRACE_PORT_H 13 | 14 | #include "trace/ctrace.h" 15 | 16 | #ifdef MADA_DEBUG 17 | 18 | EXTERN_C void rawErrorPrint(const char* msg); 19 | EXTERN_C void rawTracePrint(const char* msg); 20 | 21 | #endif 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /elf/example/README.txt: -------------------------------------------------------------------------------- 1 | readelf.exe 2 | ======= 3 | 4 | readelf.exe can read ELF information from binary and dump to screen or other output file. 5 | As a demo, readelf.exe will write the ELF information into a new ELF file. 6 | 7 | Build readelf.exe: 8 | # Add targ macro and set targ macro to 'true' to enable the function. 9 | # E.g:only enable the readelf to arm and x86 target. 10 | make -f Makefile.readelf DEBUG=true FOR_ARM=true FOR_X86=true 11 | 12 | Run readelf.exe: 13 | ./readelf.exe a.elf 14 | ./readelf.exe a.elf a.dump 15 | -------------------------------------------------------------------------------- /dex/clibs/basic/include/config/clibconfig_wince.h: -------------------------------------------------------------------------------- 1 | /*Copyright 2011 Alibaba Group*/ 2 | #ifndef CLIBS_CONFIG_WINCE_H 3 | #define CLIBS_CONFIG_WINCE_H 4 | 5 | #define C_BYTE_ORDER C_LITTLE_ENDIAN 6 | 7 | #define strdup _strdup 8 | #define stricmp _stricmp 9 | #define snprintf _snprintf 10 | #define vsnprintf _vsnprintf 11 | #define strcasecmp stricmp 12 | #define strncasecmp _strnicmp 13 | 14 | #define USE_SYSTEM_CANVAS 1 15 | #define USE_SYSTEM_FONT 1 16 | 17 | #ifdef _DEBUG 18 | #define C_MAX_TRACE_SIZE (10*1024) 19 | #endif 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /dex/clibs/basic/arch/common/thread/cthread.c: -------------------------------------------------------------------------------- 1 | /*Copyright 2011 Alibaba Group*/ 2 | /* 3 | * cthread.c 4 | * 5 | * Created on: Apr 17, 2009 6 | * Author: misa 7 | */ 8 | 9 | #include "thread/cthreadport.h" 10 | 11 | void cMutexInit(MutexT * mt) { 12 | cMutexInitPort(mt); 13 | } 14 | 15 | void cMutexLock(MutexT * mt) { 16 | cMutexLockPort(mt); 17 | } 18 | 19 | void cMutexUnlock(MutexT * mt) { 20 | cMutexUnlockPort(mt); 21 | } 22 | 23 | void cMutexDestroy(MutexT *mt) { 24 | cMutexDestroyPort(mt); 25 | } 26 | 27 | void cSleep(Int32 ms) { 28 | cSleepPort(ms); 29 | } 30 | -------------------------------------------------------------------------------- /dex/clibs/basic/arch/common/zip/czipport.h: -------------------------------------------------------------------------------- 1 | /*Copyright 2011 Alibaba Group*/ 2 | #ifndef CLIBS_ZIP_PORT_H 3 | #define CLIBS_ZIP_PORT_H 4 | 5 | #include "std/cstd.h" 6 | 7 | EXTERN_C UInt32 cZipCompFlateInit(); 8 | 9 | EXTERN_C void cZipCompFlateEnd(UInt32 id); 10 | 11 | EXTERN_C Int32 cZipDeflate(UInt32 compID, BYTE* in, UInt32 inSize, BYTE* out, UInt32 bufSize, UInt32* outSize); 12 | 13 | EXTERN_C Int32 cZipDeflateFinish(UInt32 compID, BYTE* out, UInt32 bufSize, UInt32* outSize); 14 | 15 | EXTERN_C Int32 cZipInflate(UInt32 compID, const BYTE* in, UInt32 inSize, BYTE* out, UInt32 bufSize, UInt32* outSize); 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /dex/clibs/basic/arch/common/thread/cthreadport.h: -------------------------------------------------------------------------------- 1 | /*Copyright 2011 Alibaba Group*/ 2 | /* 3 | * cthread.h 4 | * madagascar 5 | * 6 | * Created by Aaron Wang on 4/15/09. 7 | * Copyright 2009 Virtualnology. All rights reserved. 8 | * 9 | */ 10 | 11 | #ifndef CLIBS_THREAD_PORT_H 12 | #define CLIBS_THREAD_PORT_H 13 | 14 | #include "thread/cthread.h" 15 | 16 | 17 | EXTERN_C void cSleepPort(Int32 ms); 18 | 19 | EXTERN_C void cMutexInitPort(MutexT* mt); 20 | 21 | EXTERN_C void cMutexLockPort(MutexT* mt); 22 | 23 | EXTERN_C void cMutexUnlockPort(MutexT* mt); 24 | 25 | EXTERN_C void cMutexDestroyPort(MutexT* mt); 26 | 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /dex/clibs/basic/arch/unix/trace/ctraceport.c: -------------------------------------------------------------------------------- 1 | /*Copyright 2011 Alibaba Group*/ 2 | /* 3 | * ctraceport.c 4 | * madagascar 5 | * 6 | * Created by Misa.Z on 2/19/09. 7 | * Copyright 2009 Virtualnology. All rights reserved. 8 | * 9 | */ 10 | 11 | #include "trace/ctraceport.h" 12 | #include 13 | #include 14 | #include 15 | 16 | #ifdef MADA_DEBUG 17 | 18 | EXTERN_C void rawErrorPrint(const char* msg) { 19 | fprintf(stderr, "%s", msg); 20 | fflush(stderr); 21 | } 22 | 23 | EXTERN_C void rawTracePrint(const char* msg) { 24 | fprintf(stdout, "%s", msg); 25 | fflush(stdout); 26 | } 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /dex/clibs/basic/arch/android/trace/ctraceport.c: -------------------------------------------------------------------------------- 1 | /*Copyright 2011 Alibaba Group*/ 2 | /* 3 | * ctraceport.c 4 | * madagascar 5 | * 6 | * Created by Misa.Z on 2/19/09. 7 | * Copyright 2009 Virtualnology. All rights reserved. 8 | * 9 | */ 10 | 11 | #include "trace/ctraceport.h" 12 | #include 13 | #include 14 | #include 15 | 16 | #ifdef MADA_DEBUG 17 | 18 | EXTERN_C void rawErrorPrint(const char* msg) { 19 | fprintf(stderr, "%s", msg); 20 | fflush(stderr); 21 | } 22 | 23 | EXTERN_C void rawTracePrint(const char* msg) { 24 | fprintf(stdout, "%s", msg); 25 | fflush(stdout); 26 | } 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /example/ex1/Makefile: -------------------------------------------------------------------------------- 1 | CC := $(shell which clang++ > /dev/null) 2 | ifndef CC 3 | CC = $(if $(shell which clang), clang, gcc) 4 | endif 5 | 6 | EX1_OBJS+=ex1.o 7 | 8 | CFLAGS=-DFOR_DEX -D_DEBUG_ -O0 -g2 -D_SUPPORT_C11_ 9 | 10 | ex1: ex1_objs 11 | $(CC) $(EX1_OBJS) $(CFLAGS) -L../.. -lxoc -L../../com -lxcom -o ex1.exe -lstdc++ -lm 12 | @echo "SUCCESS!!" 13 | 14 | INC=-I . 15 | %.o:%.cpp 16 | @echo "BUILD $<" 17 | $(CC) $(CFLAGS) $(INC) -c $< -o $@ 18 | 19 | ex1_objs: $(EX1_OBJS) 20 | 21 | clean: 22 | @find ./ -name "*.o" | xargs rm -f 23 | @find ./ -name "*.exe" | xargs rm -f 24 | @find ./ -name "*.gr" | xargs rm -f 25 | @find ./ -name "*.tmp" | xargs rm -f 26 | -------------------------------------------------------------------------------- /opt/Makefile.ref_targmach_info.inc: -------------------------------------------------------------------------------- 1 | $(info "CONDBR:opt/Makefile.inc:REF_TARGMACH_INFO=$(REF_TARGMACH_INFO)") 2 | OPT_OBJS+=\ 3 | update_pos.o\ 4 | lsra_impl.o\ 5 | lsra_scan_in_pos.o\ 6 | lsra_scan_in_prio.o\ 7 | lt_interf_graph.o\ 8 | lt_prio_mgr.o\ 9 | ir_regssa.o\ 10 | regssainfo.o\ 11 | regd.o\ 12 | range.o\ 13 | lifetime.o\ 14 | targinfo_mgr.o\ 15 | linear_scan.o\ 16 | prologue_epilogue_inserter.o\ 17 | arg_passer.o\ 18 | gp_adjustment.o\ 19 | br_opt.o\ 20 | dynamic_stack.o\ 21 | var2offset.o\ 22 | ir_reloc_mgr.o\ 23 | igoto_opt.o\ 24 | var_lifetime.o\ 25 | var_liveness_mgr.o\ 26 | lsra_var_liveness_mgr.o\ 27 | local_var_liveness_mgr.o\ 28 | local_var_lifetime_mgr.o 29 | -------------------------------------------------------------------------------- /com/example/build.sh: -------------------------------------------------------------------------------- 1 | OPTION="-O0 -g2" 2 | FILE="../bs.cpp ../smempool.cpp ../fileobj.cpp 3 | ../byteop.cpp ../diagnostic.cpp ../sbs.cpp" 4 | g++ $OPTION use_bs.cpp $FILE -I.. -o use_bs.exe 5 | ./use_bs.exe 6 | g++ $OPTION use_list.cpp $FILE -I.. -o use_list.exe 7 | ./use_list.exe 8 | g++ $OPTION use_slist.cpp $FILE -I.. -o use_slist.exe 9 | ./use_slist.exe 10 | g++ $OPTION use_tmap.cpp $FILE -I.. -o use_tmap.exe 11 | ./use_tmap.exe 12 | g++ $OPTION use_ttab.cpp $FILE -I.. -o use_ttab.exe 13 | ./use_ttab.exe 14 | g++ $OPTION use_vector.cpp $FILE -I.. -o use_vector.exe 15 | ./use_vector.exe 16 | g++ $OPTION testbs.cpp $FILE -I.. -D_DEBUG_ -o testbs.exe 17 | ./testbs.exe 18 | -------------------------------------------------------------------------------- /dex/clibs/basic/arch/windows/dl/cdlfcn.c: -------------------------------------------------------------------------------- 1 | /*Copyright 2011 Alibaba Group*/ 2 | #include "dl/cdlfcn.h" 3 | #include 4 | #include "str/cstr.h" 5 | 6 | UInt32 cdlopen(const char* name) { 7 | return (UInt32)LoadLibrary(name); 8 | } 9 | 10 | void cdlclose(UInt32 handle) { 11 | FreeLibrary((HMODULE)handle); 12 | } 13 | 14 | void* cdlsym(UInt32 handle, const char* symname) { 15 | return (void*)GetProcAddress((HMODULE)handle, symname); 16 | } 17 | 18 | const char* cdlerror() { 19 | static char msg[64]; 20 | UInt32 err; 21 | 22 | err = GetLastError(); 23 | cSnprintf(msg, sizeof(msg), "win32 error: %u\n", err); 24 | return msg; 25 | } 26 | -------------------------------------------------------------------------------- /dex/clibs/basic/include/config/clibconfig_win32.h: -------------------------------------------------------------------------------- 1 | /*Copyright 2011 Alibaba Group*/ 2 | #ifndef CLIBS_CONFIG_WIN32_H 3 | #define CLIBS_CONFIG_WIN32_H 4 | 5 | #define C_BYTE_ORDER C_LITTLE_ENDIAN 6 | 7 | #define snprintf _snprintf 8 | #define vsnprintf _vsnprintf 9 | #define strcasecmp stricmp 10 | #define strncasecmp strnicmp 11 | 12 | #ifdef _DEBUG 13 | #define MADA_DEBUG 14 | #define C_MAX_TRACE_SIZE (10*1024) 15 | #endif 16 | 17 | #define HAVE_NO_SYSTEM_NEXTAFTER 18 | #define HAVE_NO_SYSTEM_NEXTAFTERF 19 | #define HAVE_NO_SYSTEM_RINT 20 | #define HAVE_NO_SYSTEM_REMAINDER 21 | #define HAVE_NO_SYSTEM_CBRT 22 | #define HAVE_NO_SYSTEM_EXPM1 23 | #define HAVE_NO_SYSTEM_LOG1P 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /com/example/use_vector.cpp: -------------------------------------------------------------------------------- 1 | #include "stdio.h" 2 | #include "../xcominc.h" 3 | int main() 4 | { 5 | Vector SS; 6 | 7 | SS.set(0, "The number is 10"); 8 | SS.set(1, "The number is 20"); 9 | SS.set(2, "The number is 30"); 10 | 11 | printf("Loop by index:\n"); 12 | 13 | for(VecIdx i = 0; i <= SS.get_last_idx(); i++) { 14 | printf("%s\n", SS[i]); 15 | } 16 | 17 | printf("\nReverse Iterator:\n"); 18 | 19 | for(VecIdx i = SS.get_last_idx(); !IS_VECUNDEF(i); i--) { 20 | printf("%s\n", SS[i]); 21 | } 22 | 23 | printf("\nSample Output:\n"); 24 | 25 | printf("%d\n", SS.get_last_idx()); 26 | printf("%s\n", SS[2]); 27 | 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /example/grreader/Makefile: -------------------------------------------------------------------------------- 1 | CC := $(shell which clang++ > /dev/null) 2 | ifndef CC 3 | CC = $(if $(shell which clang), clang, gcc) 4 | endif 5 | 6 | OBJS+=main.o 7 | 8 | CFLAGS=-DFOR_DEX -D_DEBUG_ -O0 -g2 -D_SUPPORT_C11_ 9 | 10 | grreader: objs 11 | $(CC) $(OBJS) $(CFLAGS) -L../.. -lxoc -L../../com -lxcom -o \ 12 | grreader.exe -lstdc++ -lm 13 | @echo "SUCCESS!!" 14 | 15 | INC=-I . 16 | %.o:%.cpp 17 | @echo "BUILD $<" 18 | $(CC) $(CFLAGS) $(INC) -c $< -o $@ 19 | 20 | objs: $(OBJS) 21 | 22 | clean: 23 | @find ./ -name "*.o" | xargs rm -f 24 | @find ./ -name "*.exe" | xargs rm -f 25 | @find ./ -name "*.gr" | xargs rm -f 26 | @find ./ -name "*.tmp" | xargs rm -f 27 | @find ./ -name "*.log" | xargs rm -f 28 | -------------------------------------------------------------------------------- /dex/clibs/basic/arch/common/time/ctimeport.h: -------------------------------------------------------------------------------- 1 | /*Copyright 2011 Alibaba Group*/ 2 | /* 3 | * ctimeport.h 4 | * 5 | * Created on: Apr 17, 2009 6 | * Author: misa 7 | */ 8 | 9 | #ifndef CLIBS_TIME_PORT_H 10 | #define CLIBS_TIME_PORT_H 11 | 12 | #include "time/ctime.h" 13 | 14 | //get time in milliseconds since GMT 1970-01-01 00:00:00 000 15 | EXTERN_C CTimeT cTimeGetTimePort(void); 16 | 17 | EXTERN_C CTimeT cTimeGetNanoTimePort(void); 18 | 19 | /** return ticks in milliseconds since the system starting */ 20 | EXTERN_C UInt32 cTimeTicksPort(void); 21 | 22 | //from -12.00 to +12.00 23 | EXTERN_C void cTimeSetTimeZonePort(Float32 tz); 24 | 25 | EXTERN_C Float32 cTimeGetTimeZonePort(void); 26 | 27 | #endif /* CTIMEPORT_H_ */ 28 | -------------------------------------------------------------------------------- /dex/clibs/basic/include/config/clibconfig_mtk.h: -------------------------------------------------------------------------------- 1 | /*Copyright 2011 Alibaba Group*/ 2 | #ifndef CLIBS_CONFIG_MTK_H 3 | #define CLIBS_CONFIG_MTK_H 4 | 5 | 6 | #define C_BYTE_ORDER C_LITTLE_ENDIAN 7 | 8 | 9 | #ifdef WIN32 10 | 11 | #define snprintf _snprintf 12 | #define vsnprintf _vsnprintf 13 | #define strcasecmp stricmp 14 | #define strncasecmp strnicmp 15 | 16 | #else 17 | 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif 21 | 22 | char* strdup(const char*); 23 | int strcasecmp(const char *str1, const char *str2); 24 | int strncasecmp(const char *str1, const char *str2, int count); 25 | 26 | #ifdef __cplusplus 27 | } 28 | #endif 29 | 30 | #endif 31 | 32 | #if 1 33 | #define C_MAX_TRACE_SIZE (10*1024) 34 | #endif 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /dex/clibs/basic/include/utils/cbuf.h: -------------------------------------------------------------------------------- 1 | /*Copyright 2011 Alibaba Group*/ 2 | #ifndef MADA_CBUFFER_H 3 | #define MADA_CBUFFER_H 4 | 5 | #include "std/cstd.h" 6 | 7 | typedef struct STBufStruct { 8 | char *buffer; 9 | UInt32 usedLen; 10 | UInt32 size; 11 | } CBufferT; 12 | 13 | EXTERN_C bool cBufExpand(CBufferT *mem, int size); 14 | EXTERN_C Int32 cBufFormatString(CBufferT *mem, const char* format, ...); 15 | EXTERN_C void cBufClear(CBufferT *mem); 16 | EXTERN_C void cBufFree(CBufferT *mem); 17 | EXTERN_C bool cBufAppend(CBufferT *mem, const void *data, UInt32 len); 18 | EXTERN_C bool cBufAppendString(CBufferT *mem, const char* str); 19 | EXTERN_C bool cBufSetValue(CBufferT *mem, const void *data, UInt32 size); 20 | 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /dex/clibs/basic/arch/common/mem/cmemport.h: -------------------------------------------------------------------------------- 1 | /*Copyright 2011 Alibaba Group*/ 2 | /* 3 | * cmemport.h 4 | * madagascar 5 | * 6 | * Created by Misa.Z on 2/19/09. 7 | * Copyright 2009 Virtualnology. All rights reserved. 8 | * 9 | */ 10 | #ifndef CLIBS_MEM_PORT_H 11 | #define CLIBS_MEM_PORT_H 12 | 13 | #include "mem/cmem.h" 14 | 15 | EXTERN_C bool cMemInitPort(); 16 | 17 | EXTERN_C void cMemFinalPort(); 18 | 19 | EXTERN_C void* cMallocPort(UInt32 size); 20 | 21 | EXTERN_C void cFreePort(void* p); 22 | 23 | EXTERN_C UInt32 cMemTotalSizePort(void); 24 | 25 | EXTERN_C UInt32 cMemUsedSizePort(void); 26 | 27 | 28 | //** added by raymond 29 | void *cMmapPort(Int32 fd, Int32 alignment, Int32 size, Int32 mode); 30 | void cMunmapPort(void *address, Int32 length); 31 | //** end 32 | #endif 33 | -------------------------------------------------------------------------------- /com/example/use_tmap.cpp: -------------------------------------------------------------------------------- 1 | #include "stdio.h" 2 | #include "../xcominc.h" 3 | int main() 4 | { 5 | TMap map; 6 | map.set(123, "Mike"); 7 | map.set(234, "Charlie"); 8 | map.set(345, "Tom"); 9 | 10 | printf("\nIterate map via string pointer:\n"); 11 | TMapIter iter; 12 | char const* str; 13 | for (int v = map.get_first(iter, &str); 14 | str != nullptr; v = map.get_next(iter, &str)) { 15 | printf("%d->%s\n", v, str); 16 | } 17 | 18 | printf("\nIterate map via iter itself:\n"); 19 | for (int v = map.get_first(iter, &str); 20 | iter.get_elem_count() != 0; v = map.get_next(iter, &str)) { 21 | printf("%d->%s\n", v, str); 22 | } 23 | 24 | printf("%d\n", map.get_elem_count()); 25 | 26 | return 0; 27 | } 28 | -------------------------------------------------------------------------------- /dex/clibs/basic/include/config/clibconfig_symbian.h: -------------------------------------------------------------------------------- 1 | /*Copyright 2011 Alibaba Group*/ 2 | #ifndef CLIBS_CONFIG_SYMBIAN_H 3 | #define CLIBS_CONFIG_SYMBIAN_H 4 | 5 | #define C_BYTE_ORDER C_LITTLE_ENDIAN 6 | 7 | #define USE_SYSTEM_BLT 0 8 | #define USE_SYSTEM_CANVAS 1 9 | #define USE_SYSTEM_FONT 1 10 | 11 | //temploray mark this #ifdef, when release, should open this macro 12 | //#ifdef _DEBUG 13 | #define C_MAX_TRACE_SIZE (10*1024) 14 | //#endif 15 | 16 | #ifndef __WINSCW__ 17 | #include 18 | //symbain, gcce or armv5 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | int snprintf(char *buf, size_t n, const char *format, ...); 24 | int vsnprintf(char* buf, size_t n, const char *format, va_list list); 25 | 26 | #ifdef __cplusplus 27 | } 28 | #endif 29 | 30 | #endif 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /dex/clibs/basic/include/thread/cthread.h: -------------------------------------------------------------------------------- 1 | /*Copyright 2011 Alibaba Group*/ 2 | /* 3 | * cthread.h 4 | * madagascar 5 | * 6 | * Created by Aaron Wang on 4/15/09. 7 | * Copyright 2009 Virtualnology. All rights reserved. 8 | * 9 | */ 10 | 11 | #ifndef CLIBS_THREAD_H 12 | #define CLIBS_THREAD_H 13 | 14 | #include "std/cstd.h" 15 | 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | 20 | typedef struct STMutex { 21 | volatile void* mutex; 22 | volatile Int32 cnt; 23 | volatile UInt32 tid; 24 | } MutexT; 25 | 26 | EXTERN_C void cSleep(Int32 ms); 27 | 28 | EXTERN_C void cMutexInit(MutexT* mt); 29 | 30 | EXTERN_C void cMutexLock(MutexT* mt); 31 | 32 | EXTERN_C void cMutexUnlock(MutexT* mt); 33 | 34 | EXTERN_C void cMutexDestroy(MutexT* mt); 35 | 36 | #ifdef __cplusplus 37 | } 38 | #endif 39 | 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /dex/clibs/basic/include/utils/clbe.h: -------------------------------------------------------------------------------- 1 | /*Copyright 2011 Alibaba Group*/ 2 | #ifndef CLIBS_LITTLE_BIG_ENDIAN_H 3 | #define CLIBS_LITTLE_BIG_ENDIAN_H 4 | 5 | #include "std/cstd.h" 6 | 7 | #define cReadLE32(p) ((p)[0]|((p)[1]<<8)|((p)[2]<<16)|((p)[3]<<24)) 8 | #define cReadLE16(p) ((p)[0]|((p)[1]<<8)) 9 | EXTERN_C UInt64 cReadLE64(BYTE* p); 10 | EXTERN_C void cWriteLE32(BYTE* dst, UInt32 num); 11 | EXTERN_C void cWriteLE16(BYTE* dst, UInt16 num); 12 | EXTERN_C void cWriteLE64(BYTE* dst, UInt64 num); 13 | 14 | #define cReadBE32(p) (((p)[0]<<24) | ((p)[1]<<16) | ((p)[2]<<8) | (p)[3]) 15 | #define cReadBE16(p) (((p)[0]<<8) | (p)[1]) 16 | EXTERN_C UInt64 cReadBE64(BYTE* p); 17 | EXTERN_C void cWriteBE32(BYTE* dst, UInt32 num); 18 | EXTERN_C void cWriteBE16(BYTE* dst, UInt16 num); 19 | EXTERN_C void cWriteBE64(BYTE* dst, UInt64 num); 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /dex/clibs/basic/arch/unix/time/ctimeport.c: -------------------------------------------------------------------------------- 1 | /*Copyright 2011 Alibaba Group*/ 2 | #include 3 | #include "time/ctimeport.h" 4 | 5 | static Float32 _sysTimeZone = 8.00; 6 | 7 | UInt32 cTimeTicksPort(void) { 8 | struct timeval tv; 9 | gettimeofday(&tv, NULL); 10 | return ((UInt64)tv.tv_sec)*1000+tv.tv_usec/1000; 11 | } 12 | 13 | //get time in milliseconds since GMT 1970-01-01 00:00:00 000 14 | CTimeT cTimeGetTimePort(void) { 15 | struct timeval tv; 16 | gettimeofday(&tv, NULL); 17 | return ((UInt64)tv.tv_sec)*1000+tv.tv_usec/1000; 18 | } 19 | 20 | //from -12.00 to +12.00 21 | void cTimeSetTimeZonePort(Float32 tz) { 22 | _sysTimeZone = tz; 23 | } 24 | 25 | Float32 cTimeGetTimeZonePort(void) { 26 | return _sysTimeZone; 27 | } 28 | 29 | void cStopSystemTimerPort() { 30 | } 31 | 32 | void cStartSystemTimerPort(Int32 pre, void* args) { 33 | } 34 | -------------------------------------------------------------------------------- /com/README.txt: -------------------------------------------------------------------------------- 1 | XCOM is a concise and readable C++ template library. 2 | 3 | The template library includes serveral basic data structures such as 4 | Vector, List, Stack, Hash, Map, BitSet, Graph, Matrix and a lot of utility 5 | functions to facilitate various C++ program development. 6 | 7 | Beside the basic structure, XCOM provides linear programming solvers, include 8 | exact simplex based on rational arithmetic, 9 | the approximate method based on double/float arithmetic, 10 | the 0-1 integer programming solver, 11 | and the mixed integer programming solver. 12 | 13 | It is well implemented and able to build whole compiler, or anyother project. 14 | 15 | The XCOM project is consist of following directories: 16 | |-- benchmark # a list of testcases to estimate runtime performance compared 17 | # to std library. 18 | |-- example # a list of concise examples to demostrate how to use XCOM. 19 | -------------------------------------------------------------------------------- /com/benchmark/README.txt: -------------------------------------------------------------------------------- 1 | Benchmark is a concise and simple program to evaluate the runtime performance 2 | of library and application. 3 | 4 | test_smempool.cpp: 5 | Evaluate the runtime performance of memory pool. 6 | command line: 7 | >g++ -std=c++0x test_smempool.cpp ../smempool.cpp -lstdc++ -DRUN_STL; time ./a.out 8 | >g++ -std=c++0x test_smempool.cpp ../smempool.cpp -lstdc++; time ./a.out 9 | 10 | test_list.cpp: 11 | Evaluate the runtime performance of List structure. 12 | command line: 13 | >g++ -std=c++0x test_list.cpp -DRUN_STL -lstdc++; time ./a.out 14 | >g++ -std=c++0x test_list.cpp -lstdc++; time ./a.out 15 | 16 | test_map.cpp: 17 | Evaluate the runtime performance of map structure. 18 | command line: 19 | >g++ -std=c++0x test_map.cpp -DRUN_STL -lstdc++; time ./a.out 20 | >g++ -std=c++0x test_map.cpp ../smempool.cpp -lstdc++; time ./a.out 21 | 22 | -------------------------------------------------------------------------------- /dex/clibs/basic/include/trace/ctrace.h: -------------------------------------------------------------------------------- 1 | /*Copyright 2012 Alibaba Group*/ 2 | #ifndef CLIBS_TRACE_H 3 | #define CLIBS_TRACE_H 4 | 5 | #include "clibconfig.h" 6 | #include "std/cstd.h" 7 | 8 | 9 | typedef enum { 10 | TRACE_LEVEL_UNKNOWN = 0, 11 | TRACE_LEVEL_VERBOSE, 12 | TRACE_LEVEL_DEBUG, 13 | TRACE_LEVEL_INFO, 14 | TRACE_LEVEL_WARN, 15 | TRACE_LEVEL_ERROR, 16 | TRACE_LEVEL_NONE, 17 | } TraceLevelT; 18 | 19 | EXTERN_C bool cTraceOut(TraceLevelT level, const char* fmt, ...); 20 | 21 | #if defined(ANDROID) && !HOST_LEMUR 22 | //TODO: define LOG_TAG in Android.mk 23 | #include "cutils/log.h" 24 | #ifndef LOGD 25 | #define LOGV ALOGV 26 | #define LOGD ALOGD 27 | #define LOGI ALOGI 28 | #define LOGW ALOGW 29 | #define LOGE ALOGE 30 | #endif 31 | 32 | #else 33 | 34 | #define LOGV printf 35 | #define LOGD printf 36 | #define LOGI printf 37 | #define LOGW printf 38 | #define LOGE printf 39 | 40 | #endif 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /example/ex1/ex1/ex1.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual Studio 2010 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ex1", "ex1.vcxproj", "{32397AE6-E058-4494-B785-734A29CFE18E}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Win32 = Debug|Win32 9 | Release|Win32 = Release|Win32 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {32397AE6-E058-4494-B785-734A29CFE18E}.Debug|Win32.ActiveCfg = Debug|Win32 13 | {32397AE6-E058-4494-B785-734A29CFE18E}.Debug|Win32.Build.0 = Debug|Win32 14 | {32397AE6-E058-4494-B785-734A29CFE18E}.Release|Win32.ActiveCfg = Release|Win32 15 | {32397AE6-E058-4494-B785-734A29CFE18E}.Release|Win32.Build.0 = Release|Win32 16 | EndGlobalSection 17 | GlobalSection(SolutionProperties) = preSolution 18 | HideSolutionNode = FALSE 19 | EndGlobalSection 20 | EndGlobal 21 | -------------------------------------------------------------------------------- /dex/clibs/basic/include/utf/cutf.h: -------------------------------------------------------------------------------- 1 | /*Copyright 2011 Alibaba Group*/ 2 | /* 3 | * cutf.h 4 | * madagascar 5 | * 6 | * Created by Misa.Z on 2/28/09. 7 | * Copyright 2009 Virtualnology. All rights reserved. 8 | * 9 | */ 10 | 11 | #ifndef CLIBS_UTF_H 12 | #define CLIBS_UTF_H 13 | 14 | #include "std/cstd.h" 15 | 16 | EXTERN_C UInt32 cUtf8Chars(const char* p, UInt32 size); 17 | 18 | EXTERN_C UInt32 cUtf8LengthOfUtf16(const UInt16* p, UInt32 size); 19 | 20 | EXTERN_C UInt32 cUtf8ToUtf16(const char* utf8, UInt32 utf8Size, UInt16* utf16, UInt32 utf16Size); 21 | 22 | EXTERN_C UInt32 cUtf16ToUtf8(const UInt16* utf16, UInt32 utf16Size, char* utf8, UInt32 utf8Size); 23 | 24 | // need free with cFree, len is the number of unichar in result 25 | EXTERN_C UInt16* cUTF16FromUTF8(const char* utf8, UInt32 utf8Size, Int32 *len); 26 | 27 | // need free with cFree, len is the size of bytes in result 28 | EXTERN_C char* cUTF8FromUTF16(const UInt16* utf16, UInt32 utf16Size, Int32 *len); 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /dex/clibs/basic/arch/android/sys/csysport.c: -------------------------------------------------------------------------------- 1 | /*Copyright 2011 Alibaba Group*/ 2 | /* 3 | * cesysport.c 4 | * madagascar 5 | * 6 | * Created by Misa.Z on 2/24/09. 7 | * Copyright 2009 Virtualnology. All rights reserved. 8 | * 9 | */ 10 | 11 | #include "sys/csysport.h" 12 | #include 13 | //#include 14 | #include 15 | 16 | bool cSysInitPort(void) { 17 | //SDL_Init(SDL_INIT_VIDEO); 18 | return true; 19 | } 20 | 21 | void cSysFinalPort(void) { 22 | //SDL_Quit(); 23 | } 24 | 25 | Int32 cSysProcessorNumberPort() 26 | { 27 | return sysconf(_SC_NPROCESSORS_CONF); 28 | } 29 | 30 | 31 | const char** cSysGetEnvBlockPort(UInt32 *blockSize) 32 | { 33 | //TODO 34 | return NULL; 35 | } 36 | 37 | const char* cSysGetEnvValuePort(const char *name) 38 | { 39 | //TODO 40 | return NULL; 41 | } 42 | 43 | void cSysExitPort(Int32 status) 44 | { 45 | exit(status); 46 | } 47 | 48 | const struct Property *cSystemInitPlatformPropertiesPort(int *num) 49 | { 50 | *num = 0; 51 | return NULL; 52 | } 53 | -------------------------------------------------------------------------------- /dex/clibs/basic/include/utils/cbytestream.h: -------------------------------------------------------------------------------- 1 | /*Copyright 2011 Alibaba Group*/ 2 | #ifndef CLIBS_BYTESTREAM_H 3 | #define CLIBS_BYTESTREAM_H 4 | 5 | #include "std/cstd.h" 6 | 7 | typedef ULong CBSHandle; 8 | 9 | EXTERN_C CBSHandle cbsInitialize(UInt32 size); 10 | 11 | EXTERN_C void cbsDestroy(CBSHandle bsh); 12 | 13 | EXTERN_C Int32 cbsWrite8(CBSHandle bsh, UInt8 d); 14 | 15 | EXTERN_C Int32 cbsWrite16(CBSHandle bsh, UInt16 d); 16 | 17 | EXTERN_C Int32 cbsWrite32(CBSHandle bsh, UInt32 d); 18 | 19 | EXTERN_C Int32 cbsWrite64(CBSHandle bsh, UInt64 d); 20 | 21 | EXTERN_C Int32 cbsWrite(CBSHandle bsh, const void* data, UInt32 size); 22 | 23 | EXTERN_C Int32 cbsSeek(CBSHandle bsh, UInt32 offset); 24 | 25 | EXTERN_C UInt32 cbsGetSize(CBSHandle bsh); 26 | EXTERN_C UInt32 cbsGetPos(CBSHandle bsh); 27 | 28 | EXTERN_C BYTE* cbsGetData(CBSHandle bsh); 29 | 30 | EXTERN_C void cbsCopyData(CBSHandle bsh, void* data, UInt32 bufSize); 31 | 32 | EXTERN_C void cbsReset(CBSHandle bsh); 33 | 34 | EXTERN_C bool cbsSetCapacity(CBSHandle bsh, UInt32 size); 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /dex/clibs/basic/arch/windows/trace/ctraceport.c: -------------------------------------------------------------------------------- 1 | /*Copyright 2011 Alibaba Group*/ 2 | /* 3 | * ctraceport.c 4 | * madagascar 5 | * 6 | * Created by Misa.Z on 2/19/09. 7 | * Copyright 2009 Virtualnology. All rights reserved. 8 | * 9 | */ 10 | 11 | #include "trace/ctraceport.h" 12 | #include 13 | #include 14 | #include 15 | 16 | #ifdef MADA_DEBUG 17 | 18 | extern int UTF8ToANSI(const char* src,int cbSrc, char *dst, int cbDst); 19 | static char _ansiBuffer[C_MAX_TRACE_SIZE]; 20 | 21 | EXTERN_C void rawErrorPrint(const char* msg) { 22 | memset(_ansiBuffer, 0, sizeof(_ansiBuffer)); 23 | UTF8ToANSI(msg, strlen(msg), _ansiBuffer, sizeof(_ansiBuffer)-1); 24 | fprintf(stderr, "%s", _ansiBuffer); 25 | fflush(stderr); 26 | } 27 | 28 | EXTERN_C void rawTracePrint(const char* msg) { 29 | memset(_ansiBuffer, 0, sizeof(_ansiBuffer)); 30 | UTF8ToANSI(msg, strlen(msg), _ansiBuffer, sizeof(_ansiBuffer)-1); 31 | fprintf(stdout, "%s", _ansiBuffer); 32 | fflush(stdout); 33 | } 34 | 35 | #endif 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /com/example/use_bs.cpp: -------------------------------------------------------------------------------- 1 | #include "stdio.h" 2 | #include "../xcominc.h" 3 | void bs() 4 | { 5 | BitSet bs; 6 | bs.bunion(1); 7 | bs.bunion(2); 8 | bs.bunion(3); 9 | 10 | printf("Iter element:\n"); 11 | for (BSIdx elem = bs.get_first(); elem != BS_UNDEF; 12 | elem = bs.get_next(elem)) { 13 | printf("%d\n", elem); 14 | } 15 | 16 | printf("\n"); 17 | printf("%d\n", bs.get_elem_count()); 18 | } 19 | 20 | void sparse_bs() 21 | { 22 | MiscBitSetMgr<100> mbsm; 23 | SBitSetCore<100> sbs; 24 | sbs.bunion(1, mbsm); 25 | sbs.bunion(99, mbsm); 26 | sbs.bunion(99, mbsm); 27 | sbs.bunion(99999, mbsm); 28 | 29 | printf("Iter element:\n"); 30 | SC*> * iter; 31 | for (int elem = sbs.get_first(&iter); 32 | elem != -1; elem = sbs.get_next(elem, &iter)) { 33 | printf("%d\n", elem); 34 | } 35 | 36 | printf("\n"); 37 | printf("%d\n", sbs.get_elem_count()); 38 | 39 | sbs.clean(mbsm); 40 | } 41 | 42 | 43 | int main() 44 | { 45 | bs(); 46 | sparse_bs(); 47 | return 0; 48 | } 49 | -------------------------------------------------------------------------------- /dex/clibs/basic/include/clibconfig.h: -------------------------------------------------------------------------------- 1 | /*Copyright 2011 Alibaba Group*/ 2 | #ifndef CLIBS_CONFIG_H 3 | #define CLIBS_CONFIG_H 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | #include "config/clibplatform.h" 10 | 11 | /* Add any platform that doesn't build using the configure system */ 12 | #if defined(ANDROID) 13 | #include "config/clibconfig_android.h" 14 | #elif defined(__UNIX_LIKE__) 15 | #include "config/clibconfig_unix.h" 16 | #elif defined(WINCE) 17 | #include "config/clibconfig_wince.h" 18 | #elif defined(__SYMBIAN32__) 19 | #include "config/clibconfig_symbian.h" 20 | #elif defined(__MTK__) 21 | #include "config/clibconfig_mtk.h" 22 | #elif defined(__BREW__) 23 | #include "config/clibconfig_brew.h" //phone platforms(wince/symbian/mtk) must before win32 for pc simulator 24 | #elif defined(__WIN32__) 25 | #include "config/clibconfig_win32.h" //phone platforms(wince/symbian/mtk) must before win32 for pc simulator 26 | #elif defined(__IPHONE__) 27 | #include "config/clibconfig_iphone.h" 28 | #else 29 | #error "unkown platform" 30 | #endif /* platform config */ 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /dex/clibs/basic/arch/android/time/ctimeport.c: -------------------------------------------------------------------------------- 1 | /*Copyright 2011 Alibaba Group*/ 2 | #include 3 | #include 4 | #include "time/ctimeport.h" 5 | 6 | static Float32 _sysTimeZone = 8.00; 7 | 8 | UInt32 cTimeTicksPort(void) { 9 | struct timeval tv; 10 | gettimeofday(&tv, NULL); 11 | return ((UInt64)tv.tv_sec)*1000+tv.tv_usec/1000; 12 | } 13 | 14 | //get time in milliseconds since GMT 1970-01-01 00:00:00 000 15 | CTimeT cTimeGetTimePort(void) { 16 | struct timeval tv; 17 | gettimeofday(&tv, NULL); 18 | return ((UInt64)tv.tv_sec)*1000+tv.tv_usec/1000; 19 | } 20 | 21 | CTimeT cTimeGetNanoTimePort(void) { 22 | #ifdef HAVE_POSIX_CLOCKS 23 | struct timespec now; 24 | clock_gettime(CLOCK_MONOTONIC, &now); 25 | return (UInt64)now.tv_sec*1000000000LL + now.tv_nsec; 26 | #else 27 | CTimeT t; 28 | t = cTimeGetTimePort(); 29 | return ((UInt64)t)*1000000; 30 | #endif 31 | } 32 | 33 | //from -12.00 to +12.00 34 | void cTimeSetTimeZonePort(Float32 tz) { 35 | _sysTimeZone = tz; 36 | } 37 | 38 | Float32 cTimeGetTimeZonePort(void) { 39 | return _sysTimeZone; 40 | } 41 | 42 | void cStopSystemTimerPort() { 43 | } 44 | 45 | void cStartSystemTimerPort(Int32 pre, void* args) { 46 | } 47 | -------------------------------------------------------------------------------- /com/example/use_list.cpp: -------------------------------------------------------------------------------- 1 | #include "stdio.h" 2 | #include "../xcominc.h" 3 | int main() 4 | { 5 | List l; 6 | 7 | l.append_tail(0); //append a new element at the end. 8 | C * ct = l.append_head(1); //append a new element at the beginning. 9 | 10 | //Insert "2" after position of first element 11 | //place before second element. 12 | l.insert_after(2, ct); 13 | 14 | //Insert "3" before the last element. 15 | //Note this function will more slower than the above. 16 | l.insert_before(3, 0); 17 | 18 | printf("Iter list element by internal iter:\n"); 19 | int i = 0; 20 | for (int e = l.get_head(); i < l.get_elem_count(); i++, e = l.get_next()) { 21 | printf("%d\n", e); 22 | } 23 | 24 | printf("Iter list element by user declared iter:\n"); 25 | C * iter; 26 | for (l.get_head(&iter); iter != nullptr; l.get_next(&iter)) { 27 | printf("%d\n", iter->val()); 28 | } 29 | 30 | printf("\nReverse Iterator:\n"); 31 | for (l.get_tail(&iter); iter != nullptr; l.get_prev(&iter)) { 32 | printf("%d\n", iter->val()); 33 | } 34 | 35 | printf("\n\n\n"); 36 | printf("%d\n", l.get_elem_count()); 37 | printf("%d\n", l.get_head_nth(2)); 38 | 39 | return 0; 40 | } 41 | -------------------------------------------------------------------------------- /com/xcominc.h: -------------------------------------------------------------------------------- 1 | #ifndef __XCOMINC_H__ 2 | #define __XCOMINC_H__ 3 | 4 | //Use OS dependent implementation 5 | //#define VARIADIC_PARAMETER_ACCESS 6 | 7 | //libxcom 8 | #include 9 | #include "ltype.h" 10 | #include "spec_type.h" 11 | #include "diagnostic.h" 12 | #include "comm_macro.h" 13 | #include "smempool.h" 14 | using namespace xcom; 15 | #include "fileobj.h" 16 | #include "byteop.h" 17 | #include "flag.h" 18 | #include "allocator.h" 19 | #include "comf.h" //used by sstl.h 20 | #include "sstl.h" 21 | #include "strbuf.h" 22 | #include "bs.h" 23 | #include "sbs.h" 24 | #include "sbs_hash.h" 25 | #include "flagset.h" 26 | #include "rpo.h" 27 | #include "sgraph.h" 28 | #include "tree.h" 29 | #include "domtree.h" 30 | #include "segtree.h" 31 | #include "rational.h" 32 | #include "flty.h" 33 | #include "bigint.h" 34 | #include "numdiff.h" 35 | #include "birational.h" 36 | #include "matt_dump.h" 37 | #include "matt.h" 38 | #include "birmat.h" 39 | #include "xmat.h" 40 | #include "tensor.h" 41 | #include "tensor2d.h" 42 | #include "xtensor.h" 43 | #include "agraph.h" 44 | #include "linsys.h" 45 | #include "lpsol.h" 46 | #include "sort.h" 47 | #include "search.h" 48 | #include "scc.h" 49 | #include "lca.h" 50 | #include "assemblebin.h" 51 | #include "log.h" 52 | #include "int_hash.h" 53 | #endif 54 | 55 | -------------------------------------------------------------------------------- /dex/clibs/basic/arch/common/sys/csysport.h: -------------------------------------------------------------------------------- 1 | /*Copyright 2011 Alibaba Group*/ 2 | /* 3 | * csysport.h 4 | * madagascar 5 | * 6 | * Created by Misa.Z on 2/19/09. 7 | * Copyright 2009 Virtualnology. All rights reserved. 8 | * 9 | */ 10 | 11 | #ifndef CLIBS_SYS_PORT_H 12 | #define CLIBS_SYS_PORT_H 13 | 14 | #include "sys/csys.h" 15 | 16 | EXTERN_C bool cSysInitPort(void); 17 | 18 | EXTERN_C void cSysFinalPort(void); 19 | 20 | EXTERN_C Int32 cSysProcessorNumberPort(); 21 | 22 | /* Retrieves the environment variables for the current process. 23 | * @param[out]: blockSize size of the environment block 24 | * @return: If ok, return the environment block. If failed, return NULL. 25 | * remark: 26 | * the format of the environment block is 27 | * Var1=Value1\0 28 | * Var2=Value2\0 29 | * Var3=Value3\0 30 | * ... 31 | * VarN=ValueN\0\0 32 | */ 33 | EXTERN_C const char** cSysGetEnvBlockPort(UInt32 *blockSize); 34 | 35 | /* Retrieves the contents of the specified variable from the environment block of the calling process. 36 | * @param name[in]: The name of the environment variable. 37 | * @return: the value of name if ok, or NULL. 38 | */ 39 | EXTERN_C const char* cSysGetEnvValuePort(const char *name); 40 | 41 | EXTERN_C void cSysExitPort(Int32 status); 42 | 43 | EXTERN_C const struct Property *cSystemInitPlatformPropertiesPort(int *num); 44 | #endif 45 | -------------------------------------------------------------------------------- /dex/clibs/basic/include/mem/cmem.h: -------------------------------------------------------------------------------- 1 | /*Copyright 2011 Alibaba Group*/ 2 | /* 3 | * cmem.h 4 | * madagascar 5 | * 6 | * Created by Misa.Z on 2/19/09. 7 | * Copyright 2009 Virtualnology. All rights reserved. 8 | * 9 | */ 10 | 11 | #ifndef CLIBS_MEM_H 12 | #define CLIBS_MEM_H 13 | 14 | #include "std/cstd.h" 15 | 16 | 17 | typedef void (*CMemAllocFailProc)(); 18 | 19 | EXTERN_C void cMemSetAllocFailProc(CMemAllocFailProc proc); 20 | 21 | EXTERN_C bool cMemInit(); 22 | 23 | EXTERN_C void cMemFinal(); 24 | 25 | 26 | EXTERN_C void* cMallocRaw(UInt32 size); 27 | #define cMalloc(size) cMallocRaw(size) 28 | 29 | EXTERN_C void cFree(void* p); 30 | 31 | EXTERN_C UInt32 cMemTotalSize(void); 32 | 33 | EXTERN_C UInt32 cMemFreeSize(void); 34 | 35 | EXTERN_C UInt32 cMemUsedSize(void); 36 | 37 | #ifdef __BREW__ 38 | #include "aeestdlib.h" 39 | #define cMemchr MEMCHR 40 | #define cMemmove MEMMOVE 41 | #define cMemcmp MEMCMP 42 | #define cMemcpy MEMCPY 43 | #define cMemset MEMSET 44 | 45 | #else 46 | #define cMemchr memchr 47 | #define cMemmove memmove 48 | #define cMemcmp memcmp 49 | #define cMemcpy memcpy 50 | #define cMemset memset 51 | #endif 52 | 53 | //** added by raymond 54 | void *cMmap(Int32 fd, Int32 alignment, Int32 size, Int32 mode); 55 | void cMunmap(void *address, Int32 length); 56 | 57 | 58 | //** end 59 | #endif 60 | -------------------------------------------------------------------------------- /dex/clibs/basic/arch/windows/time/ctimeport.c: -------------------------------------------------------------------------------- 1 | /*Copyright 2011 Alibaba Group*/ 2 | #include 3 | #include "time/ctimeport.h" 4 | 5 | //for win32 platforms that need gettimeofday 6 | 7 | /* FILETIME of Jan 1 1970 00:00:00. */ 8 | static const UInt64 epoch = LLValue(116444736000000000); 9 | 10 | int gettimeofday(struct timeval * tp, struct timezone * tzp) { 11 | FILETIME file_time; 12 | SYSTEMTIME system_time; 13 | ULARGE_INTEGER ularge; 14 | 15 | GetSystemTime(&system_time); 16 | SystemTimeToFileTime(&system_time, &file_time); 17 | ularge.LowPart = file_time.dwLowDateTime; 18 | ularge.HighPart = file_time.dwHighDateTime; 19 | 20 | tp->tv_sec = (long) ((ularge.QuadPart - epoch) / 10000000L); 21 | tp->tv_usec = (long) (system_time.wMilliseconds * 1000); 22 | 23 | return 0; 24 | } 25 | 26 | static Float32 _sysTimeZone = 8.00; 27 | 28 | UInt32 cTimeTicksPort(void) { 29 | return clock(); 30 | } 31 | 32 | //get time in milliseconds since GMT 1970-01-01 00:00:00 000 33 | CTimeT cTimeGetTimePort(void) { 34 | struct timeval tv; 35 | gettimeofday(&tv, NULL); 36 | return ((UInt64)tv.tv_sec)*1000+tv.tv_usec/1000; 37 | } 38 | 39 | //from -12.00 to +12.00 40 | void cTimeSetTimeZonePort(Float32 tz) { 41 | _sysTimeZone = tz; 42 | } 43 | 44 | Float32 cTimeGetTimeZonePort(void) { 45 | return _sysTimeZone; 46 | } 47 | -------------------------------------------------------------------------------- /dex/clibs/basic/arch/android/thread/cthreadport.c: -------------------------------------------------------------------------------- 1 | /*Copyright 2011 Alibaba Group*/ 2 | /* 3 | * cthreadport.c 4 | * 5 | * Created on: Apr 17, 2009 6 | * Author: misa 7 | */ 8 | 9 | #include "thread/cthreadport.h" 10 | #include "mem/cmemport.h" 11 | #include 12 | #include 13 | 14 | static pthread_mutexattr_t g_mutex_attr; 15 | 16 | void cSleepPort(int ms) { 17 | usleep(ms*1000); 18 | } 19 | 20 | void cMutexInitPort(MutexT * mt) { 21 | int ret; 22 | if(mt) { 23 | pthread_mutexattr_init(&g_mutex_attr); 24 | pthread_mutexattr_settype(&g_mutex_attr, PTHREAD_MUTEX_RECURSIVE); 25 | 26 | mt->mutex = (void*)cMalloc(sizeof(pthread_mutex_t)); 27 | pthread_mutex_init((pthread_mutex_t*)mt->mutex, &g_mutex_attr); 28 | } 29 | } 30 | 31 | void cMutexLockPort(MutexT * mt) { 32 | if(mt && mt->mutex) { 33 | pthread_mutex_lock((pthread_mutex_t*)mt->mutex); 34 | } 35 | } 36 | 37 | void cMutexUnlockPort(MutexT * mt) { 38 | if(mt && mt->mutex) { 39 | pthread_mutex_unlock((pthread_mutex_t*)mt->mutex); 40 | } 41 | } 42 | 43 | void cMutexDestroyPort(MutexT *mt) { 44 | if(mt && mt->mutex) { 45 | pthread_mutex_destroy((pthread_mutex_t*)mt->mutex); 46 | pthread_mutexattr_destroy(&g_mutex_attr); 47 | cFree((void*)mt->mutex); 48 | mt->mutex = NULL; 49 | } 50 | } 51 | 52 | -------------------------------------------------------------------------------- /example/grreader/grreader.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.25420.1 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "grreader", "grreader.vcxproj", "{FEEA3C48-44BB-42D6-A1A7-5274D859D48C}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {FEEA3C48-44BB-42D6-A1A7-5274D859D48C}.Debug|x64.ActiveCfg = Debug|x64 17 | {FEEA3C48-44BB-42D6-A1A7-5274D859D48C}.Debug|x64.Build.0 = Debug|x64 18 | {FEEA3C48-44BB-42D6-A1A7-5274D859D48C}.Debug|x86.ActiveCfg = Debug|Win32 19 | {FEEA3C48-44BB-42D6-A1A7-5274D859D48C}.Debug|x86.Build.0 = Debug|Win32 20 | {FEEA3C48-44BB-42D6-A1A7-5274D859D48C}.Release|x64.ActiveCfg = Release|x64 21 | {FEEA3C48-44BB-42D6-A1A7-5274D859D48C}.Release|x64.Build.0 = Release|x64 22 | {FEEA3C48-44BB-42D6-A1A7-5274D859D48C}.Release|x86.ActiveCfg = Release|Win32 23 | {FEEA3C48-44BB-42D6-A1A7-5274D859D48C}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | EndGlobal 29 | -------------------------------------------------------------------------------- /elf/example/readelf.prj/readelf.prj.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.25420.1 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "readelf.prj", "readelf.prj.vcxproj", "{A0E744E4-3A59-48E7-AE0B-5F18EBB61089}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {A0E744E4-3A59-48E7-AE0B-5F18EBB61089}.Debug|x64.ActiveCfg = Debug|x64 17 | {A0E744E4-3A59-48E7-AE0B-5F18EBB61089}.Debug|x64.Build.0 = Debug|x64 18 | {A0E744E4-3A59-48E7-AE0B-5F18EBB61089}.Debug|x86.ActiveCfg = Debug|Win32 19 | {A0E744E4-3A59-48E7-AE0B-5F18EBB61089}.Debug|x86.Build.0 = Debug|Win32 20 | {A0E744E4-3A59-48E7-AE0B-5F18EBB61089}.Release|x64.ActiveCfg = Release|x64 21 | {A0E744E4-3A59-48E7-AE0B-5F18EBB61089}.Release|x64.Build.0 = Release|x64 22 | {A0E744E4-3A59-48E7-AE0B-5F18EBB61089}.Release|x86.ActiveCfg = Release|Win32 23 | {A0E744E4-3A59-48E7-AE0B-5F18EBB61089}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | EndGlobal 29 | -------------------------------------------------------------------------------- /dex/clibs/basic/arch/common/mem/cmem.c: -------------------------------------------------------------------------------- 1 | /*Copyright 2011 Alibaba Group*/ 2 | /* 3 | * cmem.c 4 | * madagascar 5 | * 6 | * Created by Misa.Z on 2/19/09. 7 | * Copyright 2009 Virtualnology. All rights reserved. 8 | * 9 | */ 10 | 11 | #include "mem/cmem.h" 12 | #include "mem/cmemport.h" 13 | 14 | 15 | static CMemAllocFailProc _allocFailProc = NULL; 16 | 17 | void cMemSetAllocFailProc(CMemAllocFailProc proc) { 18 | _allocFailProc = proc; 19 | } 20 | 21 | bool cMemInit() { 22 | return cMemInitPort(); 23 | } 24 | 25 | void cMemFinal() { 26 | cMemFinalPort(); 27 | _allocFailProc = NULL; 28 | } 29 | 30 | UInt32 cMemTotalSize(void) { 31 | return cMemTotalSizePort(); 32 | } 33 | 34 | UInt32 cMemFreeSize(void) { 35 | return cMemTotalSize()-cMemUsedSize(); 36 | } 37 | 38 | UInt32 cMemUsedSize(void) { 39 | return cMemUsedSizePort(); 40 | } 41 | 42 | void* cMallocRaw(UInt32 size) { 43 | void* p = cMallocPort(size); 44 | if(p == NULL && _allocFailProc) { 45 | _allocFailProc(); 46 | p = cMallocPort(size); 47 | } 48 | return p; 49 | } 50 | 51 | void cFree(void* p) { 52 | cFreePort(p); 53 | } 54 | 55 | //** added by raymond 56 | 57 | void *cMmap(Int32 fd, Int32 alignment, Int32 size, Int32 mode) 58 | { 59 | return cMmapPort(fd, alignment, size, mode); 60 | } 61 | 62 | void cMunmap(void *address, Int32 length) 63 | { 64 | return cMunmapPort(address, length); 65 | } 66 | //** end 67 | -------------------------------------------------------------------------------- /dex/clibs/basic/arch/android/zip/czipport.c: -------------------------------------------------------------------------------- 1 | /*Copyright 2011 Alibaba Group*/ 2 | #include "zip/czipport.h" 3 | #include 4 | #include "mem/cmem.h" 5 | 6 | static z_stream zstrm; 7 | 8 | UInt32 cZipCompFlateInit() { 9 | cMemset(&zstrm, 0, sizeof(zstrm)); 10 | if(deflateInit2(&zstrm, Z_DEFAULT_COMPRESSION, Z_DEFLATED, -MAX_WBITS, 8, Z_DEFAULT_STRATEGY) != Z_OK) 11 | return 0; 12 | return 1; 13 | } 14 | 15 | void cZipCompFlateEnd(UInt32 id) { 16 | deflate(&zstrm, Z_FINISH); 17 | deflateEnd(&zstrm); 18 | } 19 | 20 | Int32 cZipDeflate(UInt32 compID, BYTE* in, UInt32 inSize, BYTE* out, UInt32 bufSize, UInt32* outSize) { 21 | zstrm.next_in = in; 22 | zstrm.avail_in = inSize; 23 | zstrm.next_out = out; 24 | zstrm.avail_out = bufSize; 25 | if(deflate(&zstrm, Z_NO_FLUSH) != Z_OK) 26 | return 0; 27 | *outSize = zstrm.next_out - out; 28 | return inSize - zstrm.avail_in; 29 | } 30 | 31 | Int32 cZipDeflateFinish(UInt32 compID, BYTE* out, UInt32 bufSize, UInt32* outSize) { 32 | Int32 ret; 33 | zstrm.next_out = out; 34 | zstrm.avail_out = bufSize; 35 | ret = deflate(&zstrm, Z_FINISH); 36 | *outSize = zstrm.next_out - out; 37 | if(ret == Z_STREAM_END) 38 | return 0; 39 | if(ret == Z_OK) 40 | return 1; 41 | return -1; 42 | } 43 | 44 | Int32 cZipInflate(UInt32 compID, const BYTE* in, UInt32 inSize, BYTE* out, UInt32 bufSize, UInt32* outSize) { 45 | return 0; 46 | } 47 | -------------------------------------------------------------------------------- /dex/clibs/basic/arch/unix/zip/czipport.c: -------------------------------------------------------------------------------- 1 | /*Copyright 2011 Alibaba Group*/ 2 | #include "zip/czipport.h" 3 | #include 4 | #include "mem/cmem.h" 5 | 6 | static z_stream zstrm; 7 | 8 | UInt32 cZipCompFlateInit() { 9 | cMemset(&zstrm, 0, sizeof(zstrm)); 10 | if(deflateInit2(&zstrm, Z_DEFAULT_COMPRESSION, Z_DEFLATED, -MAX_WBITS, 8, Z_DEFAULT_STRATEGY) != Z_OK) 11 | return 0; 12 | return 1; 13 | } 14 | 15 | void cZipCompFlateEnd(UInt32 id) { 16 | deflate(&zstrm, Z_FINISH); 17 | deflateEnd(&zstrm); 18 | } 19 | 20 | Int32 cZipDeflate(UInt32 compID, BYTE* in, UInt32 inSize, BYTE* out, UInt32 bufSize, UInt32* outSize) { 21 | zstrm.next_in = in; 22 | zstrm.avail_in = inSize; 23 | zstrm.next_out = out; 24 | zstrm.avail_out = bufSize; 25 | if(deflate(&zstrm, Z_NO_FLUSH) != Z_OK) 26 | return 0; 27 | *outSize = zstrm.next_out - out; 28 | return inSize - zstrm.avail_in; 29 | } 30 | 31 | Int32 cZipDeflateFinish(UInt32 compID, BYTE* out, UInt32 bufSize, UInt32* outSize) { 32 | Int32 ret; 33 | zstrm.next_out = out; 34 | zstrm.avail_out = bufSize; 35 | ret = deflate(&zstrm, Z_FINISH); 36 | *outSize = zstrm.next_out - out; 37 | if(ret == Z_STREAM_END) 38 | return 0; 39 | if(ret == Z_OK) 40 | return 1; 41 | return -1; 42 | } 43 | 44 | Int32 cZipInflate(UInt32 compID, const BYTE* in, UInt32 inSize, BYTE* out, UInt32 bufSize, UInt32* outSize) { 45 | return 0; 46 | } 47 | -------------------------------------------------------------------------------- /dex/clibs/basic/arch/windows/zip/czipport.c: -------------------------------------------------------------------------------- 1 | /*Copyright 2011 Alibaba Group*/ 2 | #include "zip/czipport.h" 3 | #include 4 | #include "mem/cmem.h" 5 | 6 | static z_stream zstrm; 7 | 8 | UInt32 cZipCompFlateInit() { 9 | cMemset(&zstrm, 0, sizeof(zstrm)); 10 | if(deflateInit2(&zstrm, Z_DEFAULT_COMPRESSION, Z_DEFLATED, -MAX_WBITS, 8, Z_DEFAULT_STRATEGY) != Z_OK) 11 | return 0; 12 | return 1; 13 | } 14 | 15 | void cZipCompFlateEnd(UInt32 id) { 16 | deflate(&zstrm, Z_FINISH); 17 | deflateEnd(&zstrm); 18 | } 19 | 20 | Int32 cZipDeflate(UInt32 compID, BYTE* in, UInt32 inSize, BYTE* out, UInt32 bufSize, UInt32* outSize) { 21 | zstrm.next_in = in; 22 | zstrm.avail_in = inSize; 23 | zstrm.next_out = out; 24 | zstrm.avail_out = bufSize; 25 | if(deflate(&zstrm, Z_NO_FLUSH) != Z_OK) 26 | return 0; 27 | *outSize = zstrm.next_out - out; 28 | return inSize - zstrm.avail_in; 29 | } 30 | 31 | Int32 cZipDeflateFinish(UInt32 compID, BYTE* out, UInt32 bufSize, UInt32* outSize) { 32 | Int32 ret; 33 | zstrm.next_out = out; 34 | zstrm.avail_out = bufSize; 35 | ret = deflate(&zstrm, Z_FINISH); 36 | *outSize = zstrm.next_out - out; 37 | if(ret == Z_STREAM_END) 38 | return 0; 39 | if(ret == Z_OK) 40 | return 1; 41 | return -1; 42 | } 43 | 44 | Int32 cZipInflate(UInt32 compID, const BYTE* in, UInt32 inSize, BYTE* out, UInt32 bufSize, UInt32* outSize) { 45 | return 0; 46 | } 47 | -------------------------------------------------------------------------------- /dex/clibs/basic/include/utils/chashtable.h: -------------------------------------------------------------------------------- 1 | /*Copyright 2011 Alibaba Group*/ 2 | #ifndef CLIBS_HASHTABLE_H 3 | #define CLIBS_HASHTABLE_H 4 | 5 | #include "std/cstd.h" 6 | 7 | typedef ULong HashTableHandle; 8 | typedef UInt32 (*HashCodeFunc)(const void* data, UInt32 len); 9 | typedef bool (*TraversalActionFunc)(void* key, UInt32 keySize, void* value, UInt32 size, void* arg); 10 | typedef void* (*HashMallocFunc)(UInt32 size); 11 | typedef void (*HashFreeFunc)(void* ptr); 12 | 13 | #define CHASH_MODE_STORE_NONE 0 14 | #define CHASH_MODE_STORE_KEY 1 15 | #define CHASH_MODE_STORE_ALL 2 16 | EXTERN_C HashTableHandle cHashCreate(HashCodeFunc hashFunc, UInt32 initCapacity, Float32 loadFactor, UInt32 mode); 17 | 18 | EXTERN_C HashTableHandle cHashCreateEx(HashCodeFunc hashFunc, HashMallocFunc mallocFunc, HashFreeFunc freeFunc, 19 | UInt32 initCapacity, Float32 loadFactor, UInt32 mode); 20 | 21 | EXTERN_C bool cHashInsert(HashTableHandle hth, const void* key, UInt32 keySize, const void* data, UInt32 dataSize); 22 | 23 | EXTERN_C void* cHashGet(HashTableHandle hth, const void* key, UInt32 keySize, UInt32* dataSize); 24 | 25 | EXTERN_C void cHashRemove(HashTableHandle hth, const void* key, UInt32 keySize); 26 | 27 | EXTERN_C void cHashTraversal(HashTableHandle hth, TraversalActionFunc action, void* arg); 28 | 29 | EXTERN_C void cHashFree(HashTableHandle hth); 30 | 31 | EXTERN_C UInt32 cHashCount(HashTableHandle hth); 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /arm/arm_sect_desc_ext.impl: -------------------------------------------------------------------------------- 1 | /*@ 2 | Copyright (c) 2013-2021, Su Zhenyu steven.known@gmail.com 3 | 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | * Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | * Neither the name of the Su Zhenyu nor the names of its contributors 15 | may be used to endorse or promote products derived from this software 16 | without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED "AS IS" AND ANY 19 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 22 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 25 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | author: Su Zhenyu 30 | @*/ 31 | -------------------------------------------------------------------------------- /reader/xcode_ext.inc: -------------------------------------------------------------------------------- 1 | /*@ 2 | Copyright (c) 2013-2021, Su Zhenyu steven.known@gmail.com 3 | 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | * Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | * Neither the name of the Su Zhenyu nor the names of its contributors 15 | may be used to endorse or promote products derived from this software 16 | without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED "AS IS" AND ANY 19 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 22 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 25 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | @*/ 29 | #include "targ_xcode_ext.inc" 30 | -------------------------------------------------------------------------------- /opt/irc_attr_ext.inc: -------------------------------------------------------------------------------- 1 | /*@ 2 | Copyright (c) 2013-2021, Su Zhenyu steven.known@gmail.com 3 | 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | * Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | * Neither the name of the Su Zhenyu nor the names of its contributors 15 | may be used to endorse or promote products derived from this software 16 | without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED "AS IS" AND ANY 19 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 22 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 25 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | @*/ 29 | #include "targ_irc_attr_ext.inc" 30 | -------------------------------------------------------------------------------- /arm/arm_sect_type_ext.inc: -------------------------------------------------------------------------------- 1 | /*@ 2 | Copyright (c) 2013-2021, Su Zhenyu steven.known@gmail.com 3 | 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | * Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | * Neither the name of the Su Zhenyu nor the names of its contributors 15 | may be used to endorse or promote products derived from this software 16 | without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED "AS IS" AND ANY 19 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 22 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 25 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | author: Su Zhenyu 30 | @*/ 31 | SH_TYPE_TEXT1, 32 | -------------------------------------------------------------------------------- /reader/xcodeinfo_ext.impl: -------------------------------------------------------------------------------- 1 | /*@ 2 | Copyright (c) 2013-2021, Su Zhenyu steven.known@gmail.com 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the Su Zhenyu nor the names of its contributors 14 | may be used to endorse or promote products derived from this software 15 | without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED "AS IS" AND ANY 18 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 21 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 23 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 24 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 25 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 26 | USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | @*/ 28 | #include "targ_xcodeinfo_ext.impl" 29 | -------------------------------------------------------------------------------- /arm/arm_opt.inc: -------------------------------------------------------------------------------- 1 | /*@ 2 | Copyright (c) 2013-2021, Su Zhenyu steven.known@gmail.com 3 | 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | * Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | * Neither the name of the Su Zhenyu nor the names of its contributors 15 | may be used to endorse or promote products derived from this software 16 | without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED "AS IS" AND ANY 19 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 22 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 25 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | author: Su Zhenyu 30 | @*/ 31 | //EXT OPT START 32 | //EXT OPT END 33 | -------------------------------------------------------------------------------- /opt/pass_type_ext.inc: -------------------------------------------------------------------------------- 1 | /*@ 2 | Copyright (c) 2013-2021, Su Zhenyu steven.known@gmail.com 3 | 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | * Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | * Neither the name of the Su Zhenyu nor the names of its contributors 15 | may be used to endorse or promote products derived from this software 16 | without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED "AS IS" AND ANY 19 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 22 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 25 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | @*/ 29 | PASS_CALC_DERIVATIVE, 30 | 31 | #include "targ_pass_type_ext.inc" 32 | -------------------------------------------------------------------------------- /arm/arm_irc_attr_ext.inc: -------------------------------------------------------------------------------- 1 | /*@ 2 | Copyright (c) 2013-2021, Su Zhenyu steven.known@gmail.com 3 | 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | * Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | * Neither the name of the Su Zhenyu nor the names of its contributors 15 | may be used to endorse or promote products derived from this software 16 | without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED "AS IS" AND ANY 19 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 22 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 25 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | author: Su Zhenyu 30 | @*/ 31 | //EXT IRC ATTR START 32 | //EXT IRC ATTR END 33 | -------------------------------------------------------------------------------- /arm/arm_pass_type_ext.inc: -------------------------------------------------------------------------------- 1 | /*@ 2 | Copyright (c) 2013-2021, Su Zhenyu steven.known@gmail.com 3 | 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | * Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | * Neither the name of the Su Zhenyu nor the names of its contributors 15 | may be used to endorse or promote products derived from this software 16 | without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED "AS IS" AND ANY 19 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 22 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 25 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | author: Su Zhenyu 30 | @*/ 31 | //EXT PASS TYPE START 32 | //EXT PASS TYPE END 33 | -------------------------------------------------------------------------------- /x64/x64.h: -------------------------------------------------------------------------------- 1 | /*@ 2 | Copyright (c) 2013-2021, Su Zhenyu steven.known@gmail.com 3 | 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | * Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | * Neither the name of the Su Zhenyu nor the names of its contributors 15 | may be used to endorse or promote products derived from this software 16 | without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED "AS IS" AND ANY 19 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 22 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 25 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | @*/ 29 | #ifndef __X64_H__ 30 | #define __X64_H__ 31 | 32 | #include "x64_elf_targinfo.h" 33 | 34 | #endif 35 | 36 | -------------------------------------------------------------------------------- /com/xtensor.cpp: -------------------------------------------------------------------------------- 1 | /*@ 2 | Copyright (c) 2013-2021, Su Zhenyu steven.known@gmail.com 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the Su Zhenyu nor the names of its contributors 14 | may be used to endorse or promote products derived from this software 15 | without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED "AS IS" AND ANY 18 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 21 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 23 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 24 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 25 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 26 | USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | @*/ 28 | #include "math.h" 29 | #include "xcominc.h" 30 | 31 | namespace xcom { 32 | } //namespace xcom 33 | -------------------------------------------------------------------------------- /score/score.h: -------------------------------------------------------------------------------- 1 | /*@ 2 | Copyright (c) 2013-2021, Su Zhenyu steven.known@gmail.com 3 | 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | * Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | * Neither the name of the Su Zhenyu nor the names of its contributors 15 | may be used to endorse or promote products derived from this software 16 | without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED "AS IS" AND ANY 19 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 22 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 25 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | @*/ 29 | #ifndef __SCORE_H__ 30 | #define __SCORE_H__ 31 | 32 | #include "score_elf_targinfo.h" 33 | 34 | #endif 35 | 36 | -------------------------------------------------------------------------------- /com/ltype.cpp: -------------------------------------------------------------------------------- 1 | /*@ 2 | XOC Release License 3 | 4 | Copyright (c) 2013-2014, Alibaba Group, All rights reserved. 5 | 6 | compiler@aliexpress.com 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | 11 | * Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | * Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | * Neither the name of the Su Zhenyu nor the names of its contributors 17 | may be used to endorse or promote products derived from this software 18 | without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 21 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS 24 | BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 26 | OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 27 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 30 | IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | author: Su Zhenyu 33 | @*/ 34 | #include "xcominc.h" 35 | -------------------------------------------------------------------------------- /opt/dbg_lang_ext.inc: -------------------------------------------------------------------------------- 1 | /*@ 2 | XOC Release License 3 | 4 | Copyright (c) 2013-2014, Alibaba Group, All rights reserved. 5 | 6 | compiler@aliexpress.com 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | 11 | * Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | * Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | * Neither the name of the Su Zhenyu nor the names of its contributors 17 | may be used to endorse or promote products derived from this software 18 | without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 21 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS 24 | BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 26 | OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 27 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 30 | IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | author: Su Zhenyu 33 | @*/ 34 | #include "targ_dbg_lang_ext.inc" 35 | -------------------------------------------------------------------------------- /elf/ph_type_ext.inc: -------------------------------------------------------------------------------- 1 | /*@ 2 | XOC Release License 3 | 4 | Copyright (c) 2013-2014, Alibaba Group, All rights reserved. 5 | 6 | compiler@aliexpress.com 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | 11 | * Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | * Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | * Neither the name of the Su Zhenyu nor the names of its contributors 17 | may be used to endorse or promote products derived from this software 18 | without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 21 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS 24 | BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 26 | OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 27 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 30 | IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | author: Su Zhenyu 33 | @*/ 34 | 35 | PH_TYPE_INTERP, 36 | 37 | #include "targ_ph_type_ext.inc" 38 | -------------------------------------------------------------------------------- /reader/targ_xcode_ext.inc: -------------------------------------------------------------------------------- 1 | /*@ 2 | Copyright (c) 2013-2021, Su Zhenyu steven.known@gmail.com 3 | 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | * Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | * Neither the name of the Su Zhenyu nor the names of its contributors 15 | may be used to endorse or promote products derived from this software 16 | without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED "AS IS" AND ANY 19 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 22 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 25 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | @*/ 29 | #if defined(FOR_JS) 30 | 31 | #elif defined(FOR_ARM) 32 | #include "../arm/arm_xcode_ext.inc" 33 | 34 | #else 35 | //No target extented x-code 36 | #endif 37 | -------------------------------------------------------------------------------- /opt/ir_high_opt.h: -------------------------------------------------------------------------------- 1 | /*@ 2 | XOC Release License 3 | 4 | Copyright (c) 2013-2014, Alibaba Group, All rights reserved. 5 | 6 | compiler@aliexpress.com 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | 11 | * Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | * Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | * Neither the name of the Su Zhenyu nor the names of its contributors 17 | may be used to endorse or promote products derived from this software 18 | without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 21 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS 24 | BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 26 | OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 27 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 30 | IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | author: Su Zhenyu 33 | @*/ 34 | #ifndef __IR_HIGH_OPT_H__ 35 | #define __IR_HIGH_OPT_H__ 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /reader/targ_xcodeinfo_ext.impl: -------------------------------------------------------------------------------- 1 | /*@ 2 | Copyright (c) 2013-2021, Su Zhenyu steven.known@gmail.com 3 | 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | * Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | * Neither the name of the Su Zhenyu nor the names of its contributors 15 | may be used to endorse or promote products derived from this software 16 | without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED "AS IS" AND ANY 19 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 22 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 25 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | @*/ 29 | #if defined(FOR_JS) 30 | 31 | #elif defined(FOR_ARM) 32 | #include "../arm/arm_xcodeinfo_ext.impl" 33 | 34 | #else 35 | //No target ir desc. 36 | #endif 37 | -------------------------------------------------------------------------------- /opt/ir_middle_opt.h: -------------------------------------------------------------------------------- 1 | /*@ 2 | XOC Release License 3 | 4 | Copyright (c) 2013-2014, Alibaba Group, All rights reserved. 5 | 6 | compiler@aliexpress.com 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | 11 | * Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | * Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | * Neither the name of the Su Zhenyu nor the names of its contributors 17 | may be used to endorse or promote products derived from this software 18 | without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 21 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS 24 | BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 26 | OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 27 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 30 | IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | author: Su Zhenyu 33 | @*/ 34 | #ifndef __IR_MIDDLE_OPT_H__ 35 | #define __IR_MIDDLE_OPT_H__ 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /opt/targ_opt.inc: -------------------------------------------------------------------------------- 1 | /*@ 2 | Copyright (c) 2013-2021, Su Zhenyu steven.known@gmail.com 3 | 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | * Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | * Neither the name of the Su Zhenyu nor the names of its contributors 15 | may be used to endorse or promote products derived from this software 16 | without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED "AS IS" AND ANY 19 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 22 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 25 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | @*/ 29 | #if defined(FOR_JS) 30 | #include "../js/js_opt.inc" 31 | 32 | #elif defined(FOR_ARM) 33 | #include "../arm/arm_opt.inc" 34 | 35 | #else 36 | //No target extented opt 37 | #endif 38 | -------------------------------------------------------------------------------- /mach/machoption.cpp: -------------------------------------------------------------------------------- 1 | /*@ 2 | Copyright (c) 2013-2021, Su Zhenyu steven.known@gmail.com 3 | 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | * Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | * Neither the name of the Su Zhenyu nor the names of its contributors 15 | may be used to endorse or promote products derived from this software 16 | without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED "AS IS" AND ANY 19 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 22 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 25 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | author: Su Zhenyu 30 | @*/ 31 | 32 | #include "machinc.h" 33 | 34 | namespace mach { 35 | 36 | bool g_do_migen = true; 37 | 38 | bool g_is_dump_migen = false; 39 | 40 | } //namespace 41 | -------------------------------------------------------------------------------- /opt/targ_desc_ext.impl: -------------------------------------------------------------------------------- 1 | /*@ 2 | Copyright (c) 2013-2021, Su Zhenyu steven.known@gmail.com 3 | 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | * Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | * Neither the name of the Su Zhenyu nor the names of its contributors 15 | may be used to endorse or promote products derived from this software 16 | without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED "AS IS" AND ANY 19 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 22 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 25 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | @*/ 29 | #if defined(FOR_JS) 30 | #include "../js/js_desc_ext.impl" 31 | 32 | #elif defined(FOR_ARM) 33 | #include "../arm/arm_desc_ext.impl" 34 | 35 | #else 36 | //No target ir desc. 37 | #endif 38 | -------------------------------------------------------------------------------- /reader/reader.h: -------------------------------------------------------------------------------- 1 | /*@ 2 | XOC Release License 3 | 4 | Copyright (c) 2013-2014, Alibaba Group, All rights reserved. 5 | 6 | compiler@aliexpress.com 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | 11 | * Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | * Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | * Neither the name of the Su Zhenyu nor the names of its contributors 17 | may be used to endorse or promote products derived from this software 18 | without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 21 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS 24 | BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 26 | OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 27 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 30 | IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | author: Su Zhenyu 33 | @*/ 34 | #include "ir_lex.h" 35 | #include "xcode.h" 36 | #include "ir_parser.h" 37 | #include "grreader.h" 38 | -------------------------------------------------------------------------------- /opt/targ_code_ext.inc: -------------------------------------------------------------------------------- 1 | /*@ 2 | Copyright (c) 2013-2021, Su Zhenyu steven.known@gmail.com 3 | 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | * Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | * Neither the name of the Su Zhenyu nor the names of its contributors 15 | may be used to endorse or promote products derived from this software 16 | without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED "AS IS" AND ANY 19 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 22 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 25 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | @*/ 29 | #if defined(FOR_JS) 30 | #include "../js/js_code_ext.inc" 31 | 32 | #elif defined(FOR_ARM) 33 | #include "../arm/arm_code_ext.inc" 34 | 35 | #else 36 | //No target extented code 37 | #endif 38 | -------------------------------------------------------------------------------- /elf/sect_type_ext.inc: -------------------------------------------------------------------------------- 1 | /*@ 2 | XOC Release License 3 | 4 | Copyright (c) 2013-2014, Alibaba Group, All rights reserved. 5 | 6 | compiler@aliexpress.com 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | 11 | * Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | * Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | * Neither the name of the Su Zhenyu nor the names of its contributors 17 | may be used to endorse or promote products derived from this software 18 | without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 21 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS 24 | BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 26 | OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 27 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 30 | IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | author: Su Zhenyu 33 | @*/ 34 | 35 | SH_TYPE_COMMENT, 36 | SH_TYPE_NOTE, //'.note.GNU-stack' 37 | 38 | #include "targ_sect_type_ext.inc" 39 | -------------------------------------------------------------------------------- /opt/targ_irc_attr_ext.inc: -------------------------------------------------------------------------------- 1 | /*@ 2 | Copyright (c) 2013-2021, Su Zhenyu steven.known@gmail.com 3 | 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | * Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | * Neither the name of the Su Zhenyu nor the names of its contributors 15 | may be used to endorse or promote products derived from this software 16 | without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED "AS IS" AND ANY 19 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 22 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 25 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | @*/ 29 | #if defined(FOR_JS) 30 | #include "../js/js_irc_attr_ext.inc" 31 | 32 | #elif defined(FOR_ARM) 33 | #include "../arm/arm_irc_attr_ext.inc" 34 | 35 | #else 36 | //No target extented code 37 | #endif 38 | -------------------------------------------------------------------------------- /com/sbs.cpp: -------------------------------------------------------------------------------- 1 | /*@ 2 | Copyright (c) 2013-2021, Su Zhenyu steven.known@gmail.com 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the Su Zhenyu nor the names of its contributors 14 | may be used to endorse or promote products derived from this software 15 | without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED "AS IS" AND ANY 18 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 21 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 23 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 24 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 25 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 26 | USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | @*/ 28 | #include "xcominc.h" 29 | 30 | namespace xcom { 31 | 32 | //The class is used to debug allocation and free of SegMgr. 33 | UINT g_segmgr_log_count = 0; 34 | UINT g_xx = 0; 35 | 36 | } //namespace xcom 37 | -------------------------------------------------------------------------------- /opt/targ_pass_type_ext.inc: -------------------------------------------------------------------------------- 1 | /*@ 2 | Copyright (c) 2013-2021, Su Zhenyu steven.known@gmail.com 3 | 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | * Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | * Neither the name of the Su Zhenyu nor the names of its contributors 15 | may be used to endorse or promote products derived from this software 16 | without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED "AS IS" AND ANY 19 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 22 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 25 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | @*/ 29 | #if defined(FOR_JS) 30 | #include "../js/js_pass_type_ext.inc" 31 | 32 | #elif defined(FOR_ARM) 33 | #include "../arm/arm_pass_type_ext.inc" 34 | 35 | #else 36 | //No target extented code 37 | #endif 38 | -------------------------------------------------------------------------------- /opt/targ_dbg_lang_ext.inc: -------------------------------------------------------------------------------- 1 | /*@ 2 | XOC Release License 3 | 4 | Copyright (c) 2013-2014, Alibaba Group, All rights reserved. 5 | 6 | compiler@aliexpress.com 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | 11 | * Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | * Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | * Neither the name of the Su Zhenyu nor the names of its contributors 17 | may be used to endorse or promote products derived from this software 18 | without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 21 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS 24 | BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 26 | OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 27 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 30 | IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | author: Su Zhenyu 33 | @*/ 34 | #if defined(FOR_JS) 35 | 36 | #elif defined(FOR_ARM) 37 | 38 | #else 39 | //No target extented code 40 | #endif 41 | -------------------------------------------------------------------------------- /dex/clibs/basic/include/sys/csys.h: -------------------------------------------------------------------------------- 1 | /*Copyright 2011 Alibaba Group*/ 2 | /* 3 | * csys.h 4 | * madagascar 5 | * 6 | * Created by Aaron Wang on 4/15/09. 7 | * Copyright 2009 Virtualnology. All rights reserved. 8 | * 9 | */ 10 | 11 | #ifndef CLIBS_SYS_H 12 | #define CLIBS_SYS_H 13 | 14 | #include "std/cstd.h" 15 | 16 | struct Property { 17 | const char *key; 18 | const char *value; 19 | }; 20 | 21 | typedef struct STPlatformInfo { 22 | const char* os; 23 | const char* osVersion; 24 | Int64 CPUFrequency; 25 | bool isSupportCamera; 26 | bool isSupportGPS; 27 | bool isSupportGravity; 28 | } CPlatformInfoT; 29 | 30 | EXTERN_C bool cSysInit(void); 31 | 32 | EXTERN_C void cSysFinal(void); 33 | 34 | EXTERN_C void cSysGetPlatform(CPlatformInfoT* info); 35 | 36 | EXTERN_C void cSysSetRootPath(const char* path); 37 | 38 | EXTERN_C const char* cSysGetRootPath(); 39 | 40 | EXTERN_C Int32 cSysProcessorNumber(); 41 | 42 | /* Retrieves the environment variables for the current process. 43 | * @param[out]: blockSize size of the environment block 44 | * @return: If ok, return the environment block. If failed, return NULL. 45 | * remark: 46 | * the format of the environment block is 47 | * Var1=Value1\0 48 | * Var2=Value2\0 49 | * Var3=Value3\0 50 | * ... 51 | * VarN=ValueN\0\0 52 | */ 53 | EXTERN_C const char** cSysGetEnvBlock(UInt32 *blockSize); 54 | 55 | /* Retrieves the contents of the specified variable from the environment block of the calling process. 56 | * @param name[in]: The name of the environment variable. 57 | * @return: the value of name if ok, or NULL. 58 | */ 59 | EXTERN_C const char* cSysGetEnvValue(const char *name); 60 | 61 | EXTERN_C void cSysExit(Int32 status); 62 | 63 | EXTERN_C const struct Property *cSystemInitPlatformProperties(int *num); 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | XOC is released under the BSD 3-Clause license. 2 | =============================================================================== 3 | 4 | XOC Release License 5 | 6 | Copyright (c) 2016-2021, Su Zhenyu steven.known@gmail.com 7 | 8 | All rights reserved. 9 | 10 | Redistribution and use in source and binary forms, with or without 11 | modification, are permitted provided that the following conditions are met: 12 | 13 | * Redistributions of source code must retain the above copyright 14 | notice, this list of conditions and the following disclaimer. 15 | * Redistributions in binary form must reproduce the above copyright 16 | notice, this list of conditions and the following disclaimer in the 17 | documentation and/or other materials provided with the distribution. 18 | * Neither the name of the Su Zhenyu nor the names of its contributors 19 | may be used to endorse or promote products derived from this software 20 | without specific prior written permission. 21 | 22 | THIS SOFTWARE IS PROVIDED "AS IS" AND ANY 23 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 24 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25 | DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 26 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 27 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 28 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 29 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 31 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | 33 | =============================================================================== 34 | -------------------------------------------------------------------------------- /dex/include/aot.h: -------------------------------------------------------------------------------- 1 | /*@ 2 | XOC Release License 3 | 4 | Copyright (c) 2013-2014, Alibaba Group, All rights reserved. 5 | 6 | compiler@aliexpress.com 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | 11 | * Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | * Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | * Neither the name of the Su Zhenyu nor the names of its contributors 17 | may be used to endorse or promote products derived from this software 18 | without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 21 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS 24 | BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 26 | OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 27 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 30 | IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | author: GongKai, JinYue 33 | @*/ 34 | #ifndef __AOT_H__ 35 | #define __AOT_H__ 36 | 37 | bool aotDrGenCode(const DexFile* pDexFile, DexMethod* pDexMethod, LCodeData* codeData); 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /opt/goto_opt.h: -------------------------------------------------------------------------------- 1 | /*@ 2 | XOC Release License 3 | 4 | Copyright (c) 2013-2014, Alibaba Group, All rights reserved. 5 | 6 | compiler@aliexpress.com 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | 11 | * Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | * Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | * Neither the name of the Su Zhenyu nor the names of its contributors 17 | may be used to endorse or promote products derived from this software 18 | without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 21 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS 24 | BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 26 | OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 27 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 30 | IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | author: Su Zhenyu 33 | @*/ 34 | #ifndef _GOTO_OPT_H_ 35 | #define _GOTO_OPT_H_ 36 | 37 | namespace xoc { 38 | 39 | bool goto_opt(IRCFG * cfg, IRBB * bb); 40 | 41 | } //namespace xoc 42 | #endif 43 | -------------------------------------------------------------------------------- /arm/arm_code_ext.inc: -------------------------------------------------------------------------------- 1 | /*@ 2 | Copyright (c) 2013-2021, Su Zhenyu steven.known@gmail.com 3 | 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | * Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | * Neither the name of the Su Zhenyu nor the names of its contributors 15 | may be used to endorse or promote products derived from this software 16 | without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED "AS IS" AND ANY 19 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 22 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 25 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | author: Su Zhenyu 30 | @*/ 31 | //EXT CODE START 32 | IR_RELU, //f(x)=max(0,x) 33 | IR_SOFTMAX, //f(x)=exp(x)/sigma(exp(x_i)) 34 | IR_CONV, //f(x)=conv(x,w) 35 | IR_CONV_OPND_GRAD, //x' = f(conv',x,w), w' = g(conv',x,w) 36 | IR_SIGMOID, 37 | IR_TANH, 38 | //EXT CODE END 39 | -------------------------------------------------------------------------------- /opt/goto_opt.cpp: -------------------------------------------------------------------------------- 1 | /*@ 2 | XOC Release License 3 | 4 | Copyright (c) 2013-2014, Alibaba Group, All rights reserved. 5 | 6 | compiler@aliexpress.com 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | 11 | * Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | * Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | * Neither the name of the Su Zhenyu nor the names of its contributors 17 | may be used to endorse or promote products derived from this software 18 | without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 21 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS 24 | BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 26 | OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 27 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 30 | IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | author: Su Zhenyu 33 | @*/ 34 | #include "cominc.h" 35 | 36 | namespace xoc { 37 | 38 | bool IRCFG::goto_opt(IRBB * bb) 39 | { 40 | DUMMYUSE(bb); 41 | return false; 42 | } 43 | 44 | } //namespace xoc 45 | -------------------------------------------------------------------------------- /opt/targ_decl_ext.h: -------------------------------------------------------------------------------- 1 | /*@ 2 | Copyright (c) 2013-2021, Su Zhenyu steven.known@gmail.com 3 | 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | * Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | * Neither the name of the Su Zhenyu nor the names of its contributors 15 | may be used to endorse or promote products derived from this software 16 | without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED "AS IS" AND ANY 19 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 22 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 25 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | @*/ 29 | #ifndef _TARG_DECL_EXT_H_ 30 | #define _TARG_DECL_EXT_H_ 31 | 32 | #if defined(FOR_JS) 33 | #include "../js/js_decl_ext.h" 34 | 35 | #elif defined(FOR_ARM) 36 | #include "../arm/arm_decl_ext.h" 37 | 38 | #else 39 | //No target ir decl. 40 | #endif 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /dex/linealloc/drAlloc.h: -------------------------------------------------------------------------------- 1 | /*@ 2 | XOC Release License 3 | 4 | Copyright (c) 2013-2014, Alibaba Group, All rights reserved. 5 | 6 | compiler@aliexpress.com 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | 11 | * Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | * Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | * Neither the name of the Su Zhenyu nor the names of its contributors 17 | may be used to endorse or promote products derived from this software 18 | without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 21 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS 24 | BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 26 | OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 27 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 30 | IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | author: GongKai, JinYue 33 | @*/ 34 | #ifndef DEX_READER_ALLOC 35 | #define DEX_READER_ALLOC 36 | 37 | bool drLinearInit(void); 38 | void* drLinearAlloc(size_t size); 39 | void drLinearFree(void); 40 | #endif 41 | -------------------------------------------------------------------------------- /opt/const.h: -------------------------------------------------------------------------------- 1 | /*@ 2 | XOC Release License 3 | 4 | Copyright (c) 2013-2014, Alibaba Group, All rights reserved. 5 | 6 | compiler@aliexpress.com 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | 11 | * Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | * Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | * Neither the name of the Su Zhenyu nor the names of its contributors 17 | may be used to endorse or promote products derived from this software 18 | without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 21 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS 24 | BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 26 | OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 27 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 30 | IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | author: Su Zhenyu 33 | @*/ 34 | #ifndef __CONST_H__ 35 | #define __CONST_H__ 36 | 37 | namespace xoc { 38 | 39 | #define PRNO_UNDEF ((PRNO)0) //The undefined value of prno. 40 | 41 | } //namespace xoc 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /opt/targ_utils_ext.h: -------------------------------------------------------------------------------- 1 | /*@ 2 | Copyright (c) 2013-2021, Su Zhenyu steven.known@gmail.com 3 | 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | * Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | * Neither the name of the Su Zhenyu nor the names of its contributors 15 | may be used to endorse or promote products derived from this software 16 | without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED "AS IS" AND ANY 19 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 22 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 25 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | @*/ 29 | #ifndef _TARG_UTILS_EXT_H_ 30 | #define _TARG_UTILS_EXT_H_ 31 | 32 | #if defined(FOR_JS) 33 | #include "../js/js_utils_ext.h" 34 | 35 | #elif defined(FOR_ARM) 36 | #include "../arm/arm_utils_ext.h" 37 | 38 | #else 39 | //No target ir utils. 40 | #endif 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /dex/include/xassert.h: -------------------------------------------------------------------------------- 1 | /*@ 2 | XOC Release License 3 | 4 | Copyright (c) 2013-2014, Alibaba Group, All rights reserved. 5 | 6 | compiler@aliexpress.com 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | 11 | * Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | * Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | * Neither the name of the Su Zhenyu nor the names of its contributors 17 | may be used to endorse or promote products derived from this software 18 | without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 21 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS 24 | BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 26 | OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 27 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 30 | IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | author: GongKai, JinYue 33 | @*/ 34 | #ifndef _XASSERT_ 35 | #define _XASSERT_ 36 | #define ABORT()\ 37 | do {\ 38 | *(UInt32*)(0x0)=0xdeaddaad;\ 39 | } while (0) 40 | #endif 41 | 42 | #include "trace/ctrace.h" 43 | -------------------------------------------------------------------------------- /elf/targ_ph_type_ext.inc: -------------------------------------------------------------------------------- 1 | /*@ 2 | XOC Release License 3 | 4 | Copyright (c) 2013-2014, Alibaba Group, All rights reserved. 5 | 6 | compiler@aliexpress.com 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | 11 | * Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | * Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | * Neither the name of the Su Zhenyu nor the names of its contributors 17 | may be used to endorse or promote products derived from this software 18 | without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 21 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS 24 | BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 26 | OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 27 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 30 | IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | author: Su Zhenyu 33 | @*/ 34 | 35 | #if defined(FOR_ARM) 36 | #include "../arm/arm_ph_type_ext.inc" 37 | 38 | #elif defined(FOR_X86) 39 | #include "../x86/x86_ph_type_ext.inc" 40 | 41 | #else 42 | //No sect desc. 43 | #endif 44 | -------------------------------------------------------------------------------- /elf/targ_sect_type_ext.inc: -------------------------------------------------------------------------------- 1 | /*@ 2 | XOC Release License 3 | 4 | Copyright (c) 2013-2014, Alibaba Group, All rights reserved. 5 | 6 | compiler@aliexpress.com 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | 11 | * Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | * Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | * Neither the name of the Su Zhenyu nor the names of its contributors 17 | may be used to endorse or promote products derived from this software 18 | without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 21 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS 24 | BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 26 | OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 27 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 30 | IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | author: Su Zhenyu 33 | @*/ 34 | 35 | #if defined(FOR_ARM) 36 | #include "../arm/arm_sect_type_ext.inc" 37 | 38 | #elif defined(FOR_X86) 39 | #include "../x86/x86_sect_type_ext.inc" 40 | 41 | #else 42 | //No sect desc. 43 | #endif 44 | -------------------------------------------------------------------------------- /dex/clibs/basic/arch/common/sys/csys.c: -------------------------------------------------------------------------------- 1 | /*Copyright 2011 Alibaba Group*/ 2 | 3 | #include "sys/csys.h" 4 | #include "sys/csysport.h" 5 | #include "str/cstr.h" 6 | 7 | static char _sysRootPath[512]; 8 | 9 | bool cSysInit(void) { 10 | return cSysInitPort(); 11 | } 12 | 13 | void cSysFinal(void) { 14 | cSysFinalPort(); 15 | } 16 | char* str_osVersion[20]; 17 | char* str_osName[40]; 18 | void cSysGetPlatform(CPlatformInfoT* info) { 19 | if(info) { 20 | #if defined(__IPHONEOS__) 21 | cSysGetPlatformPort(info); 22 | #elif defined(WINCE) 23 | info->os = "WINCE"; 24 | #elif defined(__SYMBIAN32__) 25 | info->os = "SYMBIAN"; 26 | #elif defined(__BREW__) 27 | info->os = "SYMBIAN"; 28 | #elif defined(__MTK__) 29 | info->os = "MTK"; 30 | #elif defined(__UNIX_LIKE__) 31 | info->os = "UNIX"; 32 | #elif defined(__WIN32__) 33 | info->os = "IPHONEOS"; 34 | info->CPUFrequency=400000; 35 | info->osVersion="V1"; 36 | info->isSupportCamera=true; 37 | info->isSupportGPS=true; 38 | info->isSupportGravity=true; 39 | #else 40 | info->os = "UNKNOWN"; 41 | #endif 42 | 43 | } 44 | } 45 | 46 | void cSysSetRootPath(const char* path) { 47 | cStrncpy(_sysRootPath, path, 511); 48 | } 49 | 50 | const char* cSysGetRootPath() { 51 | return _sysRootPath; 52 | } 53 | 54 | Int32 cSysProcessorNumber() 55 | { 56 | return cSysProcessorNumberPort(); 57 | } 58 | 59 | const char** cSysGetEnvBlock(UInt32 *blockSize) 60 | { 61 | return cSysGetEnvBlockPort(blockSize); 62 | } 63 | 64 | const char* cSysGetEnvValue(const char *name) 65 | { 66 | return cSysGetEnvValuePort(name); 67 | } 68 | 69 | void cSysExit(Int32 status) 70 | { 71 | cSysExitPort(status); 72 | } 73 | 74 | const struct Property *cSystemInitPlatformProperties(Int32 *num) 75 | { 76 | return cSystemInitPlatformPropertiesPort(num); 77 | } 78 | 79 | -------------------------------------------------------------------------------- /elf/targ_sect_desc_ext.impl: -------------------------------------------------------------------------------- 1 | /*@ 2 | XOC Release License 3 | 4 | Copyright (c) 2013-2014, Alibaba Group, All rights reserved. 5 | 6 | compiler@aliexpress.com 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | 11 | * Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | * Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | * Neither the name of the Su Zhenyu nor the names of its contributors 17 | may be used to endorse or promote products derived from this software 18 | without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 21 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS 24 | BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 26 | OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 27 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 30 | IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | author: Su Zhenyu 33 | @*/ 34 | 35 | #if defined(FOR_ARM) 36 | #include "../arm/arm_sect_desc_ext.impl" 37 | 38 | #elif defined(FOR_X86) 39 | #include "../x86/x86_sect_desc_ext.impl" 40 | 41 | #else 42 | //No sect desc. 43 | #endif 44 | -------------------------------------------------------------------------------- /com/example/use_ttab.cpp: -------------------------------------------------------------------------------- 1 | #include "stdio.h" 2 | #include "../xcominc.h" 3 | class CompareString { 4 | public: 5 | bool is_equ(char const* s1, char const* s2) const 6 | { 7 | return xcom::xstrcmp(s1, s2) == 0; 8 | } 9 | 10 | bool is_less(char const* s1, char const* s2) const 11 | { 12 | while (s1 != nullptr && s2 != nullptr) { 13 | if (*s1 < *s2) { return true; } 14 | s1++; 15 | s2++; 16 | } 17 | if (s1 == nullptr) { return true; } 18 | return false; 19 | } 20 | 21 | char const* createKey(char const* t) { return t; } 22 | }; 23 | void string_tab() 24 | { 25 | TTab tab; 26 | tab.append("Mike"); 27 | tab.append("Tom"); 28 | tab.append("Jerry"); 29 | 30 | printf("\nIterate tab:\n"); 31 | TTabIter iter; 32 | 33 | for (char const* v = tab.get_first(iter); 34 | v != nullptr; v = tab.get_next(iter)) { 35 | printf("%s\n", v); 36 | } 37 | 38 | printf("%d\n", tab.get_elem_count()); 39 | } 40 | 41 | 42 | void int_tab() 43 | { 44 | TTab tab; 45 | tab.append(123); 46 | tab.append(234); 47 | tab.append(345); 48 | 49 | printf("\nIterate tab:\n"); 50 | TTabIter iter; 51 | 52 | //If you are going to use integer to judge if the iteration 53 | //determinate, you should guarantee 0 is not in the TTab. 54 | for (int v = tab.get_first(iter); 55 | v != 0; v = tab.get_next(iter)) { 56 | printf("%d\n", v); 57 | } 58 | 59 | printf("\nIterate tab via iter itself:\n"); 60 | for (int v = tab.get_first(iter); 61 | iter.get_elem_count() != 0; v = tab.get_next(iter)) { 62 | printf("%d\n", v); 63 | } 64 | 65 | printf("%d\n", tab.get_elem_count()); 66 | } 67 | 68 | 69 | int main() 70 | { 71 | int_tab(); 72 | string_tab(); 73 | return 0; 74 | } 75 | -------------------------------------------------------------------------------- /mach/machoption.h: -------------------------------------------------------------------------------- 1 | /*@ 2 | Copyright (c) 2013-2021, Su Zhenyu steven.known@gmail.com 3 | 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | * Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | * Neither the name of the Su Zhenyu nor the names of its contributors 15 | may be used to endorse or promote products derived from this software 16 | without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED "AS IS" AND ANY 19 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 22 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 25 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | author: Su Zhenyu 30 | @*/ 31 | #ifndef __MACH_OPTION_H__ 32 | #define __MACH_OPTION_H__ 33 | 34 | namespace mach { 35 | 36 | //Perform Machine Insruction Generation. 37 | extern bool g_do_migen; 38 | 39 | //Dump Machine Insruction Generation. 40 | extern bool g_is_dump_migen; 41 | 42 | } //namespace 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /com/numdiff.cpp: -------------------------------------------------------------------------------- 1 | /*@ 2 | Copyright (c) 2013-2021, Su Zhenyu steven.known@gmail.com 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the Su Zhenyu nor the names of its contributors 14 | may be used to endorse or promote products derived from this software 15 | without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED "AS IS" AND ANY 18 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 21 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 23 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 24 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 25 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 26 | USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | @*/ 28 | #include "xcominc.h" 29 | 30 | namespace xcom { 31 | 32 | // 33 | //START NumDiff 34 | // 35 | Float NumDiff::calcNumDiff(Float x, Float delta) 36 | { 37 | ASSERTN(delta != Float(0), ("divided by 0.0")); 38 | return (func(x+delta) - func(x)) / delta; 39 | } 40 | //END NumDiff 41 | 42 | 43 | 44 | 45 | } //namespace xcom 46 | -------------------------------------------------------------------------------- /dex/clibs/basic/arch/unix/mem/cmemport.c: -------------------------------------------------------------------------------- 1 | /*Copyright 2011 Alibaba Group*/ 2 | /* 3 | * cmemport.c 4 | * madagascar 5 | * 6 | * Created by Misa.Z on 2/19/09. 7 | * Copyright 2009 Virtualnology. All rights reserved. 8 | * 9 | */ 10 | 11 | #include "mem/cmemport.h" 12 | #include "errno/cerrno.h" 13 | 14 | #include 15 | #include 16 | #include 17 | 18 | #include 19 | 20 | bool cMemInitPort() { 21 | return true; 22 | } 23 | 24 | void cMemFinalPort() { 25 | } 26 | 27 | void* cMallocPort(UInt32 size) { 28 | void* ret = NULL; 29 | 30 | ret = malloc(size); 31 | if(ret == NULL) { 32 | _cerrno = ERROR_MEM_ALLOC; 33 | return NULL; 34 | } 35 | 36 | return ret; 37 | } 38 | 39 | void cFreePort(void* p) { 40 | if(p == NULL) 41 | return; 42 | 43 | free(p); 44 | } 45 | 46 | UInt32 cMemTotalSizePort(void) { 47 | return 64*1024*1024; 48 | } 49 | 50 | UInt32 cMemUsedSizePort(void) { 51 | return 1*1024*1024; 52 | } 53 | 54 | void *cMmapPort(Int32 fd, Int32 alignment, Int32 size, Int32 mode) 55 | { 56 | void *result; 57 | Int32 prot; 58 | Int32 flags; 59 | 60 | switch (mode) { 61 | case 1: 62 | prot = PROT_READ; 63 | flags = MAP_SHARED; 64 | break; 65 | case 2: 66 | prot = PROT_READ | PROT_WRITE; 67 | flags = MAP_SHARED; 68 | break; 69 | case 4: 70 | prot = PROT_READ; 71 | flags = MAP_PRIVATE; 72 | break; 73 | default: 74 | return -1; 75 | } 76 | 77 | result = mmap(NULL, (size_t) (size & 0x7fffffff), prot, flags, fd, (off_t) (alignment & 0x7fffffff)); 78 | 79 | if (result == MAP_FAILED) 80 | return -1; 81 | 82 | return result; 83 | } 84 | 85 | void cMunmapPort(void *address, Int32 length) 86 | { 87 | munmap(address, length); 88 | } 89 | 90 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | xoc 2 | ===== 3 | 4 | Welcome to use XOC 5 | 6 | What does XOC mean? 7 | eXtremely Optimizing Compiler. 8 | We build XOC compiler that intent to be a finely honed tool to squeezing 9 | the last performance out of ordinary code. 10 | 11 | Contribution and License Agreement. 12 | The XOC Repo is licensed under the BSD license. 13 | If you contribute code to this project, you are implicitly allowing your 14 | code to be distributed under the BSD license. 15 | 16 | Your ideas have no limits. 17 | Surprisingly powerful. 18 | Why let programming tools shackle your mind? 19 | XOC was designed for extensibility. 20 | Tailoring and retargeting the compiler is easy, and fun. 21 | 22 | Truly open. 23 | XOC is not just open-source, it is open from end to end. 24 | You can tune its syntax, add new instructions, integrate arbitrary system 25 | capabilities, enforce custom policies, add specific optimizations ... 26 | 27 | XOC is a compiler infrastructure that provides multi-level IR operations, 28 | flexibility, and the capability of representing almost all popular languages. 29 | There are two level IR representations used throughout all phases of the 30 | compilation. You can use XOC to perform optimization, program analysis or build diagnostic tools. 31 | 32 | The main documentation is in doc/Manual.txt. 33 | 34 | Build libxoc.a on Linux: 35 | Default build host is Linux 36 | ```cmd 37 | cd xoc 38 | make -f Makefile.xoc 39 | ``` 40 | 41 | Build libxoc.a on Windows: 42 | ```cmd 43 | cd xoc 44 | make -f Makefile.xoc WIN=1 45 | ``` 46 | 47 | How to Contribute : 48 | All contributors should own the rights to any code you contribute, and 49 | that you give us permission to use that code in XOC. 50 | You maintain the copyright on that code. 51 | Submit a pull request for your changes. A project developer will review 52 | your work and then merge your request into the project. 53 | -------------------------------------------------------------------------------- /win/misc.h: -------------------------------------------------------------------------------- 1 | /*@ 2 | XOC Release License 3 | 4 | Copyright (c) 2013-2014, Alibaba Group, All rights reserved. 5 | 6 | compiler@aliexpress.com 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | 11 | * Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | * Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | * Neither the name of the Su Zhenyu nor the names of its contributors 17 | may be used to endorse or promote products derived from this software 18 | without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 21 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS 24 | BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 26 | OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 27 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 30 | IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | author: Su Zhenyu 33 | @*/ 34 | #ifndef _MISC_H_ 35 | #define _MISC_H_ 36 | 37 | //This file only used on Windows. 38 | 39 | void tstart(); 40 | 41 | //Return time, in ps, ns, ms, or h:min:sec. 42 | //buf: recommend to larger than 256 bytes at least. 43 | char * tend(char * buf, UINT buflen) 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /dex/clibs/basic/arch/android/mem/cmemport.c: -------------------------------------------------------------------------------- 1 | /*Copyright 2011 Alibaba Group*/ 2 | /* 3 | * cmemport.c 4 | * madagascar 5 | * 6 | * Created by Misa.Z on 2/19/09. 7 | * Copyright 2009 Virtualnology. All rights reserved. 8 | * 9 | */ 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | #include "mem/cmemport.h" 17 | #include "errno/cerrno.h" 18 | 19 | bool cMemInitPort() { 20 | return true; 21 | } 22 | 23 | void cMemFinalPort() { 24 | } 25 | 26 | void* cMallocPort(UInt32 size) { 27 | void* ret = NULL; 28 | 29 | ret = malloc(size); 30 | if(ret == NULL) { 31 | _cerrno = ERROR_MEM_ALLOC; 32 | return NULL; 33 | } 34 | 35 | return ret; 36 | } 37 | 38 | void cFreePort(void* p) { 39 | if(p == NULL) 40 | return; 41 | 42 | free(p); 43 | } 44 | 45 | UInt32 cMemTotalSizePort(void) { 46 | return 64*1024*1024; 47 | } 48 | 49 | UInt32 cMemUsedSizePort(void) { 50 | return 1*1024*1024; 51 | } 52 | 53 | 54 | 55 | 56 | void *cMmapPort(Int32 fd, Int32 alignment, Int32 size, Int32 mode) 57 | { 58 | void *result; 59 | Int32 prot; 60 | Int32 flags; 61 | 62 | switch (mode) { 63 | case 1: 64 | prot = PROT_READ; 65 | flags = MAP_SHARED; 66 | break; 67 | case 2: 68 | prot = PROT_READ | PROT_WRITE; 69 | flags = MAP_SHARED; 70 | break; 71 | case 4: 72 | prot = PROT_READ; 73 | flags = MAP_PRIVATE; 74 | break; 75 | default: 76 | return NULL; 77 | } 78 | result = mmap(NULL, (size_t) (size & 0x7fffffff), prot, flags, fd, (off_t) (alignment & 0x7fffffff)); 79 | if (result == MAP_FAILED) 80 | return NULL; 81 | 82 | return result; 83 | } 84 | 85 | void cMunmapPort(void *address, Int32 length) 86 | { 87 | munmap(address, length); 88 | } 89 | 90 | 91 | 92 | 93 | -------------------------------------------------------------------------------- /opt/ir_ext.cpp: -------------------------------------------------------------------------------- 1 | /*@ 2 | Copyright (c) 2013-2021, Su Zhenyu steven.known@gmail.com 3 | 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | * Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | * Neither the name of the Su Zhenyu nor the names of its contributors 15 | may be used to endorse or promote products derived from this software 16 | without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED "AS IS" AND ANY 19 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 22 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 25 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | author: Su Zhenyu 30 | @*/ 31 | #include "cominc.h" 32 | #include "comopt.h" 33 | 34 | namespace xoc { 35 | 36 | bool IR::isVirtualOp() const 37 | { 38 | switch (getCode()) { 39 | SWITCH_CASE_EXT_VSTMT: return true; 40 | default:; //Nothing to do. 41 | } 42 | return false; 43 | } 44 | 45 | } //namespace xoc 46 | -------------------------------------------------------------------------------- /dex/dex_hook.h: -------------------------------------------------------------------------------- 1 | /*@ 2 | XOC Release License 3 | 4 | Copyright (c) 2013-2014, Alibaba Group, All rights reserved. 5 | 6 | compiler@aliexpress.com 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | 11 | * Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | * Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | * Neither the name of the Su Zhenyu nor the names of its contributors 17 | may be used to endorse or promote products derived from this software 18 | without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 21 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS 24 | BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 26 | OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 27 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 30 | IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | author: Su Zhenyu 33 | @*/ 34 | #ifndef _DEX_HOOK_H_ 35 | #define _DEX_HOOK_H_ 36 | 37 | #include "dex_pass_mgr.h" 38 | #include "dex_call_graph.h" 39 | #include "dex_region.h" 40 | #include "dex_region_mgr.h" 41 | #include "dex_cp.h" 42 | #include "dex_rp.h" 43 | #include "dex_aa.h" 44 | #include "dex_cfg.h" 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /elf/sect_desc_ext.impl: -------------------------------------------------------------------------------- 1 | /*@ 2 | XOC Release License 3 | 4 | Copyright (c) 2013-2014, Alibaba Group, All rights reserved. 5 | 6 | compiler@aliexpress.com 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | 11 | * Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | * Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | * Neither the name of the Su Zhenyu nor the names of its contributors 17 | may be used to endorse or promote products derived from this software 18 | without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 21 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS 24 | BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 26 | OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 27 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 30 | IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | author: Su Zhenyu 33 | @*/ 34 | 35 | { SH_TYPE_COMMENT, S_PROGBITS, PH_TYPE_UNDEF, 36 | SF_MERGE|SF_STRINGS, ELF_VAL_UNDEF, ELF_VAL_UNDEF, ".comment" }, 37 | 38 | { SH_TYPE_NOTE, S_PROGBITS, PH_TYPE_UNDEF, 39 | ELF_VAL_UNDEF, ELF_VAL_UNDEF, ELF_VAL_UNDEF, ".note" }, 40 | 41 | #include "targ_sect_desc_ext.impl" 42 | -------------------------------------------------------------------------------- /dex/clibs/basic/include/str/cstr.h: -------------------------------------------------------------------------------- 1 | /*Copyright 2011 Alibaba Group*/ 2 | /* 3 | * cstring.h 4 | * madagascar 5 | * 6 | * Created by Aaron Wang on 4/15/09. 7 | * Copyright 2009 Virtualnology. All rights reserved. 8 | * 9 | */ 10 | 11 | #ifndef CLIBS_STRING_H 12 | #define CLIBS_STRING_H 13 | 14 | #include "std/cstd.h" 15 | 16 | 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | #ifndef __BREW__ 26 | #define cStrcat strcat 27 | #define cStrchr strchr 28 | #define cStrrchr strrchr 29 | #define cStrcmp strcmp 30 | #define cStrcpy strcpy 31 | #define cStrlen strlen 32 | #define cStrncat strncat 33 | #define cStrncmp strncmp 34 | #define cStrncpy strncpy 35 | #define cStrstr strstr 36 | #define cStrcasecmp strcasecmp 37 | #define cStrncasecmp strncasecmp 38 | #define cSnprintf snprintf 39 | #define cVsnprintf vsnprintf 40 | #define cSprintf sprintf 41 | #define cStrdup strdup 42 | #define cIsspace isspace 43 | 44 | #define cAtoi atoi 45 | #define cAtof atof 46 | #else /* !__BREW__ */ 47 | #include "AEEStdLib.h" 48 | #define cStrcat STRCAT 49 | #define cStrchr STRCHR 50 | #define cStrrchr STRRCHR 51 | #define cStrcmp STRCMP 52 | #define cStrcpy STRCPY 53 | #define cStrlen STRLEN 54 | #define cStrncat(src,dst,len) STRCAT((src),(dst)) 55 | #define cStrncmp STRNCMP 56 | #define cStrncpy STRNCPY 57 | #define cStrstr STRSTR 58 | #define cStrcasecmp STRICMP 59 | #define cStrncasecmp STRNICMP 60 | #define cSnprintf SNPRINTF 61 | #define cVsnprintf VSNPRINTF 62 | #define cSprintf SPRINTF 63 | #define cStrdup STRDUP 64 | #define cIsspace(c) ((c) == ' ' || (c) == '\r' || (c) == '\n' || (c) == '\t' || (c) == '\v') 65 | 66 | #define cAtoi ATOI 67 | #define cAtof ATOF 68 | #endif /* __BREW__ */ 69 | 70 | /** replace all 'pat' to 'rep' in 'str' */ 71 | void cStrcrep(char* str, char pat, char rep); 72 | 73 | Int32 cStrLastIndexOf(const char* str, char c); 74 | 75 | #ifdef __cplusplus 76 | } 77 | #endif 78 | 79 | #endif 80 | -------------------------------------------------------------------------------- /elf/elfinc.h: -------------------------------------------------------------------------------- 1 | /*@ 2 | Copyright (c) 2013-2021, Su Zhenyu steven.known@gmail.com 3 | 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | * Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | * Neither the name of the Su Zhenyu nor the names of its contributors 15 | may be used to endorse or promote products derived from this software 16 | without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED "AS IS" AND ANY 19 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 22 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 25 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | @*/ 29 | #include "../com/xcominc.h" 30 | #include "../opt/cominc.h" 31 | #include "../opt/act_mgr.h" 32 | #include "elf_header.h" 33 | #include "elf_targinfo.h" 34 | #include "linker_relax.h" 35 | #include "elf_mgr.h" 36 | #include "elf_option.h" 37 | #include "linker_pass_mgr.h" 38 | #include "linker_mgr.h" 39 | #include "misc_elf_mgr.h" 40 | #include "../opt/dwarf.h" 41 | #include "cache_miss.h" 42 | 43 | using namespace elf; 44 | -------------------------------------------------------------------------------- /com/allocator.h: -------------------------------------------------------------------------------- 1 | /*@ 2 | Copyright (c) 2013-2021, Su Zhenyu steven.known@gmail.com 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the Su Zhenyu nor the names of its contributors 14 | may be used to endorse or promote products derived from this software 15 | without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED "AS IS" AND ANY 18 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 21 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 23 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 24 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 25 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 26 | USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | @*/ 28 | //Note new and delete could not declared in xcom namespace. 29 | //Replacement new-operator allocates memory from common pool. 30 | inline void * operator new(size_t size, xcom::SMemPool * handler) 31 | { 32 | ASSERT0(handler); 33 | return smpoolMalloc(size, handler, MEM_COMM); 34 | } 35 | 36 | inline void operator delete(void *, xcom::SMemPool * handler) 37 | { 38 | ASSERT0_DUMMYUSE(handler); 39 | } 40 | 41 | -------------------------------------------------------------------------------- /dex/lir/drcode.h: -------------------------------------------------------------------------------- 1 | /*@ 2 | XOC Release License 3 | 4 | Copyright (c) 2013-2014, Alibaba Group, All rights reserved. 5 | 6 | compiler@aliexpress.com 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | 11 | * Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | * Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | * Neither the name of the Su Zhenyu nor the names of its contributors 17 | may be used to endorse or promote products derived from this software 18 | without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 21 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS 24 | BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 26 | OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 27 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 30 | IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | author: GongKai, JinYue 33 | @*/ 34 | #ifndef __DRCODE_H__ 35 | #define __DRCODE_H__ 36 | 37 | void d2rMethod( 38 | D2Dpool* pool, 39 | DexFile* pDexFile, 40 | const DexMethod* pDexMethod, 41 | const DexClassDef* classdef, 42 | RegionMgr* rumgr, 43 | List * rulist); 44 | void d2rCopyData(D2Dpool* pool, BYTE* endAddr); 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /com/log.h: -------------------------------------------------------------------------------- 1 | /*@ 2 | Copyright (c) 2013-2021, Su Zhenyu steven.known@gmail.com 3 | 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | * Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | * Neither the name of the Su Zhenyu nor the names of its contributors 15 | may be used to endorse or promote products derived from this software 16 | without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED "AS IS" AND ANY 19 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 22 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 25 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | @*/ 29 | #ifndef __LOG_H__ 30 | #define __LOG_H__ 31 | 32 | namespace xcom { 33 | 34 | //Log information to file. 35 | //indent: the number of blank indent. 36 | //Note the indent starts after the last '\n'. 37 | //e.g:the output information is "\n\ncontent", the indent starts at the second 38 | //'\n'. 39 | void log(FILE * h, UINT indent, CHAR const* format, ...); 40 | void log(FILE * h, UINT indent, CHAR const* format, va_list args); 41 | 42 | } //namespace xcom 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /dex/dex2dex/d2d_dexlib.h: -------------------------------------------------------------------------------- 1 | /*@ 2 | XOC Release License 3 | 4 | Copyright (c) 2013-2014, Alibaba Group, All rights reserved. 5 | 6 | compiler@aliexpress.com 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | 11 | * Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | * Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | * Neither the name of the Su Zhenyu nor the names of its contributors 17 | may be used to endorse or promote products derived from this software 18 | without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 21 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS 24 | BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 26 | OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 27 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 30 | IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | author: GongKai, JinYue 33 | @*/ 34 | #ifndef _D2D_DEXLIB_H 35 | #define _D2D_DEXLIB_H 36 | 37 | #define MIN_INT ((Int32)1<<(sizeof(Int32)*8 - 1)) 38 | 39 | #include "std/cstd.h" 40 | 41 | #ifdef __cplusplus 42 | extern "C" { 43 | #endif 44 | int signedLeb128Size(Int32 value); 45 | void writeSignedLeb128(Int8* ptr, Int32 value); 46 | #ifdef __cplusplus 47 | } 48 | #endif 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /opt/ir_verify_ext.h: -------------------------------------------------------------------------------- 1 | /*@ 2 | Copyright (c) 2013-2021, Su Zhenyu steven.known@gmail.com 3 | 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | * Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | * Neither the name of the Su Zhenyu nor the names of its contributors 15 | may be used to endorse or promote products derived from this software 16 | without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED "AS IS" AND ANY 19 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 22 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 25 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | @*/ 29 | #ifndef _IR_VERIFY_EXT_H_ 30 | #define _IR_VERIFY_EXT_H_ 31 | 32 | namespace xoc { 33 | 34 | bool verifyVST(IR const* ir, Region const* rg); 35 | bool verifyVIST(IR const* ir, Region const* rg); 36 | bool verifyVSTPR(IR const* ir, Region const* rg); 37 | bool verifyBROADCAST(IR const* ir, Region const* rg); 38 | bool verifyMaskOp(IR const* ir, Region const* rg); 39 | bool verifyMaskSelectToRes(IR const* ir, Region const* rg); 40 | 41 | } //namespace xoc 42 | #endif 43 | -------------------------------------------------------------------------------- /opt/cfg.cpp: -------------------------------------------------------------------------------- 1 | /*@ 2 | Copyright (c) 2013-2021, Su Zhenyu steven.known@gmail.com 3 | 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | * Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | * Neither the name of the Su Zhenyu nor the names of its contributors 15 | may be used to endorse or promote products derived from this software 16 | without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED "AS IS" AND ANY 19 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 22 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 25 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | author: Su Zhenyu 30 | @*/ 31 | #include "cominc.h" 32 | #include "comopt.h" 33 | 34 | namespace xoc { 35 | 36 | // 37 | //START CfgOptCtx 38 | // 39 | CfgOptCtx::CfgOptCtx(OptCtx * toc, ActMgr * am) : PassCtx(toc, am) 40 | { 41 | reinit(); 42 | } 43 | 44 | 45 | CfgOptCtx::CfgOptCtx(CfgOptCtx const& src) : PassCtx(src) 46 | { 47 | reinit(); 48 | copyTopDownInfo(src); 49 | } 50 | //END CfgOptCtx 51 | 52 | } //namespace xoc 53 | -------------------------------------------------------------------------------- /dex/dex2dex/cmdline.h: -------------------------------------------------------------------------------- 1 | /*@ 2 | XOC Release License 3 | 4 | Copyright (c) 2013-2014, Alibaba Group, All rights reserved. 5 | 6 | compiler@aliexpress.com 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | 11 | * Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | * Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | * Neither the name of the Su Zhenyu nor the names of its contributors 17 | may be used to endorse or promote products derived from this software 18 | without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 21 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS 24 | BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 26 | OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 27 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 30 | IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | author: Su Zhenyu 33 | @*/ 34 | #ifndef _CMD_LINE_ 35 | #define _CMD_LINE_ 36 | 37 | bool processCommandLine(UINT argc, CHAR const* argv[]); 38 | 39 | extern CHAR const* g_dex_file_path; 40 | extern INT g_output_file_handler; 41 | extern INT g_source_file_handler; 42 | extern CHAR const* g_logfile_name; 43 | 44 | //Set true to disable all auxiliary informations which will output to stdout. 45 | extern bool g_silence; 46 | #endif 47 | -------------------------------------------------------------------------------- /dex/clibs/basic/arch/common/utils/clbe.c: -------------------------------------------------------------------------------- 1 | /*Copyright 2011 Alibaba Group*/ 2 | #include "utils/clbe.h" 3 | #include "mem/cmem.h" 4 | 5 | UInt64 cReadLE64(BYTE* p) { 6 | UInt64 ret = 0; 7 | 8 | /** 9 | ret |= p[4]; 10 | ret |= p[5] << 8; 11 | ret |= p[6] << 16; 12 | ret |= p[7] << 24; 13 | ret <<= 32; 14 | ret |= p[0]; 15 | ret |= p[1] << 8; 16 | ret |= p[2] << 16; 17 | ret |= p[3] << 24; 18 | */ 19 | cMemcpy(&ret, p, 8); 20 | return ret; 21 | } 22 | 23 | void cWriteLE32(BYTE* dst, UInt32 num) { 24 | if(dst == NULL) 25 | return; 26 | dst[0] = num & 0xff; 27 | dst[1] = (num >> 8) & 0xff; 28 | dst[2] = (num >> 16) & 0xff; 29 | dst[3] = num >> 24; 30 | } 31 | 32 | void cWriteLE16(BYTE* dst, UInt16 num) { 33 | if(dst == NULL) 34 | return; 35 | dst[0] = num & 0xff; 36 | dst[1] = num >> 8; 37 | } 38 | 39 | void cWriteLE64(BYTE* dst, UInt64 num) { 40 | if(dst == NULL) 41 | return; 42 | cMemcpy(dst, &num, 8); 43 | } 44 | 45 | UInt64 cReadBE64(BYTE* p) { 46 | UInt64 ret = 0; 47 | 48 | ret |= p[3]; 49 | ret |= p[2] << 8; 50 | ret |= p[1] << 16; 51 | ret |= (UInt32)p[0] << 24; 52 | ret <<= 32; 53 | ret |= p[7]; 54 | ret |= p[6] << 8; 55 | ret |= p[5] << 16; 56 | ret |= (UInt32)(p[4] << 24); 57 | return ret; 58 | } 59 | 60 | void cWriteBE32(BYTE* dst, UInt32 num) { 61 | if(dst == NULL) 62 | return; 63 | dst[0] = num >> 24; 64 | dst[1] = (num >> 16) & 0xff; 65 | dst[2] = (num >> 8) & 0xff; 66 | dst[3] = num & 0xff; 67 | } 68 | 69 | void cWriteBE16(BYTE* dst, UInt16 num) { 70 | if(dst == NULL) 71 | return; 72 | dst[0] = num >> 8; 73 | dst[1] = num & 0xff; 74 | } 75 | 76 | void cWriteBE64(BYTE* dst, UInt64 num) { 77 | BYTE* p; 78 | 79 | if(dst == NULL) 80 | return; 81 | p = (BYTE*)# 82 | dst[0] = p[7]; 83 | dst[1] = p[6]; 84 | dst[2] = p[5]; 85 | dst[3] = p[4]; 86 | dst[4] = p[3]; 87 | dst[5] = p[2]; 88 | dst[6] = p[1]; 89 | dst[7] = p[0]; 90 | } 91 | -------------------------------------------------------------------------------- /opt/status.cpp: -------------------------------------------------------------------------------- 1 | /*@ 2 | Copyright (c) 2013-2021, Su Zhenyu steven.known@gmail.com 3 | 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | * Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | * Neither the name of the Su Zhenyu nor the names of its contributors 15 | may be used to endorse or promote products derived from this software 16 | without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED "AS IS" AND ANY 19 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 22 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 25 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | author: Su Zhenyu 30 | @*/ 31 | #include "cominc.h" 32 | #include "comopt.h" 33 | 34 | namespace xoc { 35 | 36 | void Status::dump(Region const* rg) const 37 | { 38 | if (!rg->isLogMgrInit()) { return; } 39 | LogMgr * lm = rg->getLogMgr(); 40 | FILE * h = lm->getFileHandler(); 41 | ASSERT0(h); 42 | xcom::DefFlagSet::dump(h); 43 | for (BSIdx i = get_first(); i != BS_UNDEF; i = get_next(i)) { 44 | note(lm, "\n%s", getStatusName((FlagSetIdx)i)); 45 | } 46 | } 47 | 48 | } //namespace xoc 49 | -------------------------------------------------------------------------------- /dex/dex_pass_mgr.h: -------------------------------------------------------------------------------- 1 | /*@ 2 | XOC Release License 3 | 4 | Copyright (c) 2013-2014, Alibaba Group, All rights reserved. 5 | 6 | compiler@aliexpress.com 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | 11 | * Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | * Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | * Neither the name of the Su Zhenyu nor the names of its contributors 17 | may be used to endorse or promote products derived from this software 18 | without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 21 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS 24 | BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 26 | OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 27 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 30 | IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | author: Su Zhenyu 33 | @*/ 34 | #ifndef _DEX_PASS_MGR_H_ 35 | #define _DEX_PASS_MGR_H_ 36 | 37 | class DexPassMgr : public PassMgr { 38 | public: 39 | DexPassMgr(Region * rg) : PassMgr(rg) {} 40 | virtual ~DexPassMgr() {} 41 | 42 | virtual Pass * allocCFG(); 43 | virtual Pass * allocDCE(); 44 | virtual Pass * allocCopyProp(); 45 | virtual Pass * allocRP(); 46 | 47 | virtual void performScalarOpt(OptCtx & oc); 48 | }; 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /opt/status.h: -------------------------------------------------------------------------------- 1 | /*@ 2 | Copyright (c) 2013-2021, Su Zhenyu steven.known@gmail.com 3 | 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | * Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | * Neither the name of the Su Zhenyu nor the names of its contributors 15 | may be used to endorse or promote products derived from this software 16 | without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED "AS IS" AND ANY 19 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 22 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 25 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | @*/ 29 | #ifndef _STATUS_H_ 30 | #define _STATUS_H_ 31 | 32 | namespace xoc { 33 | 34 | class Status : public xcom::DefFlagSet { 35 | public: 36 | void dump(Region const* rg) const; 37 | 38 | //Return the number of status. 39 | UINT get_status_num() const { return get_flag_num(); } 40 | 41 | //Return the name of status. 42 | virtual CHAR const* getStatusName(FlagSetIdx s) const 43 | { DUMMYUSE(s); return "NONAME"; } 44 | }; 45 | 46 | } //namespace xoc 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /dex/dex2dex/d2d_comm.h: -------------------------------------------------------------------------------- 1 | /*@ 2 | XOC Release License 3 | 4 | Copyright (c) 2013-2014, Alibaba Group, All rights reserved. 5 | 6 | compiler@aliexpress.com 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | 11 | * Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | * Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | * Neither the name of the Su Zhenyu nor the names of its contributors 17 | may be used to endorse or promote products derived from this software 18 | without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 21 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS 24 | BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 26 | OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 27 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 30 | IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | author: GongKai, JinYue 33 | @*/ 34 | #ifndef _D2D_COMM_H_ 35 | #define _D2D_COMM_H_ 36 | 37 | //avoid confict instruction: kSparseSwitchSignature 0x0200 and lc_nop 0x0200 38 | #define KVM_kPackedSwitchSignature 0x10FF 39 | #define KVM_kSparseSwitchSignature 0x20FF 40 | #define KVM_kArrayDataSignature 0x30FF 41 | 42 | #define L2D_kPackedSwitchSignature 0x0100 43 | #define L2D_kSparseSwitchSignature 0x0200 44 | #define L2D_kArrayDataSignature 0x0300 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /opt/commoninc.h: -------------------------------------------------------------------------------- 1 | /*@ 2 | XOC Release License 3 | 4 | Copyright (c) 2013-2014, Alibaba Group, All rights reserved. 5 | 6 | compiler@aliexpress.com 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | 11 | * Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | * Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | * Neither the name of the Su Zhenyu nor the names of its contributors 17 | may be used to endorse or promote products derived from this software 18 | without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 21 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS 24 | BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 26 | OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 27 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 30 | IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | author: Su Zhenyu 33 | @*/ 34 | #ifndef __COMMONINC_H__ 35 | #define __COMMONINC_H__ 36 | //common included files 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include "../com/xcominc.h" //libxcom 43 | #include "symtab.h" 44 | #include "option.h" 45 | #include "optctx.h" 46 | #include "targ_const_info.h" 47 | #include "logmgr.h" 48 | #include "util.h" 49 | #include "label.h" 50 | #include "timer.h" 51 | #endif 52 | -------------------------------------------------------------------------------- /com/Makefile.option: -------------------------------------------------------------------------------- 1 | #SET DEBUG FLAG 2 | ifeq ($(DEBUG),) 3 | #Default build mode is DEBUG mode. 4 | DEBUG=true 5 | endif 6 | 7 | ifeq ($(DEBUG), true) 8 | #Add predefined macro if build host is Windows. 9 | CFLAGS+=-D_DEBUG_ 10 | CFLAGS+=-O0 -g2 11 | else 12 | CFLAGS+=-O2 13 | endif 14 | 15 | #The code attemps to compile an empty C++ file with the warning option, and 16 | #return YES if compilation is successful, otherwise return NO. The return info 17 | #is record in a makefile variable. 18 | CC_SUPPORTS_WNO_MISMATCHED_NEW_DELETE := $(shell echo "" | \ 19 | $(CC) -Wno-mismatched-new-delete -c -x c++ \ 20 | - > /dev/null 2>&1 && echo YES || echo NO) 21 | ifeq ($(CC_SUPPORTS_WNO_MISMATCHED_NEW_DELETE),YES) 22 | $(info "NOTE:$(CC) SUPPORT -Wno-mismatched-new-delete") 23 | #The warning is NOT effect without optimization, thus code must be 24 | #compiled with the -O2 option in order for GCC to find the bug. 25 | CFLAGS+=-Wno-mismatched-new-delete 26 | else 27 | $(info "NOTE:$(CC) DOES NOT SUPPORT -Wno-mismatched-new-delete") 28 | endif 29 | 30 | #ADD OS FLAG 31 | ifeq ($(WIN), true) 32 | $(info "ON WINDOWS") 33 | #Add predefined macro if build host is Windows. 34 | CFLAGS+=-D_ON_WINDOWS_ 35 | ifeq ($(WSL), true) 36 | CFLAGS+=-D_USE_GCC_ 37 | endif 38 | else 39 | $(info "ON LINUX OR UNIX") 40 | CFLAGS+=-D_USE_GCC_ 41 | endif 42 | 43 | #SET COMPILER 44 | ifeq ($(WIN), true) 45 | $(info "ON WINDOWS") 46 | ifeq ($(WSL), true) 47 | ifndef CC 48 | CC:=$(shell which clang++ > /dev/null) 49 | ifndef CC 50 | CC=$(if $(shell which clang),clang.exe,gcc.exe) 51 | endif 52 | endif 53 | else 54 | $(error "THERE IS NO CC COMPILER AVAIABLE WITHOUT WSL ENVIRONMENT") 55 | endif 56 | ifndef CC 57 | $(error "THERE IS NO CC COMPILER AVAIABLE") 58 | #$(info "CC is defined="$(CC)) 59 | endif 60 | else 61 | $(info "ON LINUX OR UNIX") 62 | ifndef CC 63 | CC:=$(shell which clang++ > /dev/null) 64 | ifndef CC 65 | CC=$(if $(shell which clang),clang,gcc) 66 | endif 67 | endif 68 | ifndef CC 69 | $(error "THERE IS NO CC COMPILER AVAIABLE") 70 | endif 71 | endif 72 | -------------------------------------------------------------------------------- /mach/machinc.h: -------------------------------------------------------------------------------- 1 | /*@ 2 | Copyright (c) 2013-2021, Su Zhenyu steven.known@gmail.com 3 | 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | * Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | * Neither the name of the Su Zhenyu nor the names of its contributors 15 | may be used to endorse or promote products derived from this software 16 | without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED "AS IS" AND ANY 19 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 22 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 25 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | author: Su Zhenyu 30 | @*/ 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include "../opt/cominc.h" //targ_interface need RegionMgr. 36 | #include "../xgen/reg.h" 37 | #include "../xgen/regfile.h" 38 | #include "../xgen/targ_interface.h" 39 | #include "migen.h" 40 | #include "minst_field.h" 41 | #include "minst.h" 42 | #include "minst_desc.h" 43 | #include "minst_decl.h" 44 | #include "minst_mgr.h" 45 | #include "minst_field.h" 46 | #include "ir2minst.h" 47 | #include "mi_reloc_mgr.h" 48 | #include "machoption.h" 49 | -------------------------------------------------------------------------------- /opt/ir_dump_ext.h: -------------------------------------------------------------------------------- 1 | /*@ 2 | Copyright (c) 2013-2021, Su Zhenyu steven.known@gmail.com 3 | 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | * Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | * Neither the name of the Su Zhenyu nor the names of its contributors 15 | may be used to endorse or promote products derived from this software 16 | without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED "AS IS" AND ANY 19 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 22 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 25 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | @*/ 29 | #ifndef _IR_DUMP_EXT_H_ 30 | #define _IR_DUMP_EXT_H_ 31 | 32 | namespace xoc { 33 | 34 | void dumpATOMCAS(IR const* ir, Region const* rg, IRDumpCtx<> & ctx); 35 | void dumpATOMINC(IR const* ir, Region const* rg, IRDumpCtx<> & ctx); 36 | void dumpBROADCAST(IR const* ir, Region const* rg, IRDumpCtx<> & ctx); 37 | void dumpVSTPR(IR const* ir, Region const* rg, IRDumpCtx<> & ctx); 38 | void dumpMaskOp(IR const* ir, Region const* rg, IRDumpCtx<> & ctx); 39 | void dumpMaskSelectToRes(IR const* ir, Region const* rg, IRDumpCtx<> & ctx); 40 | 41 | } //namespace xoc 42 | #endif 43 | -------------------------------------------------------------------------------- /opt/targ_const_info.h: -------------------------------------------------------------------------------- 1 | /*@ 2 | XOC Release License 3 | 4 | Copyright (c) 2013-2014, Alibaba Group, All rights reserved. 5 | 6 | compiler@aliexpress.com 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | 11 | * Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | * Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | * Neither the name of the Su Zhenyu nor the names of its contributors 17 | may be used to endorse or promote products derived from this software 18 | without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 21 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS 24 | BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 26 | OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 27 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 30 | IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | author: Su Zhenyu 33 | @*/ 34 | #ifndef __TARG_CONST_INFO_H__ 35 | #define __TARG_CONST_INFO_H__ 36 | 37 | #if defined(FOR_X86) 38 | #include "../x86/x86_const_info.h" 39 | 40 | #elif defined(FOR_ARM) 41 | #include "../arm/arm_const_info.h" 42 | 43 | #elif defined(FOR_PAC) 44 | #include "../pac/pac_const_info.h" 45 | 46 | #elif defined(FOR_DEX) 47 | #include "../dex/dex_const_info.h" 48 | 49 | #elif defined(FOR_JS) 50 | #include "../js/js_const_info.h" 51 | 52 | #else 53 | #error "No target info" 54 | #endif 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /opt/storage_space.cpp: -------------------------------------------------------------------------------- 1 | /*@ 2 | Copyright (c) 2013-2021, Su Zhenyu steven.known@gmail.com 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the Su Zhenyu nor the names of its contributors 14 | may be used to endorse or promote products derived from this software 15 | without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED "AS IS" AND ANY 18 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 21 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 23 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 24 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 25 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 26 | USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | @*/ 28 | #include "cominc.h" 29 | #include "comopt.h" 30 | 31 | namespace xoc { 32 | 33 | StorageSpaceDesc const g_storagespace_desc[] = { 34 | { SS_UNDEF, "undef", }, 35 | { SS_GLOBAL, "global", }, 36 | { SS_REG, "reg", }, 37 | { SS_SPM, "spm", }, 38 | { SS_PARAM, "param", }, 39 | { SS_SHARED, "shared", }, 40 | { SS_STACK, "stack", }, 41 | { SS_READONLY, "readonly", }, 42 | { SS_ANY, "any", }, 43 | }; 44 | 45 | CHAR const* StorageSpaceDesc::getName(StorageSpace ss) 46 | { 47 | return g_storagespace_desc[ss].name; 48 | } 49 | 50 | } //namespace xoc 51 | -------------------------------------------------------------------------------- /dex/clibs/basic/arch/windows/mem/cmemport.c: -------------------------------------------------------------------------------- 1 | /*Copyright 2011 Alibaba Group*/ 2 | /* 3 | * cmemport.c 4 | * madagascar 5 | * 6 | * Created by Misa.Z on 2/19/09. 7 | * Copyright 2009 Virtualnology. All rights reserved. 8 | * 9 | */ 10 | 11 | #include "mem/cmemport.h" 12 | #include "errno/cerrno.h" 13 | 14 | #include 15 | #include 16 | 17 | #include 18 | 19 | bool cMemInitPort() { 20 | return true; 21 | } 22 | 23 | void cMemFinalPort() { 24 | } 25 | 26 | void* cMallocPort(UInt32 size) { 27 | void* ret = NULL; 28 | #ifdef WIN32 29 | printf("");//yangyang added not to crash in windows 30 | #endif 31 | ret = malloc(size); 32 | if(ret == NULL) { 33 | _cerrno = ERROR_MEM_ALLOC; 34 | return NULL; 35 | } 36 | 37 | return ret; 38 | } 39 | 40 | void cFreePort(void* p) { 41 | if(p == NULL) 42 | return; 43 | 44 | free(p); 45 | } 46 | 47 | UInt32 cMemTotalSizePort(void) { 48 | return 64*1024*1024; 49 | } 50 | 51 | UInt32 cMemUsedSizePort(void) { 52 | return 1*1024*1024; 53 | } 54 | 55 | void *cMmapPort(Int32 fd, Int32 alignment, Int32 size, Int32 mode) 56 | { 57 | HANDLE mmaping; 58 | void *result; 59 | Int32 prot; 60 | Int32 mapmode; 61 | 62 | switch (mode) { 63 | case 1: 64 | prot = PAGE_READONLY; 65 | mapmode = FILE_MAP_READ; 66 | break; 67 | case 2: 68 | prot = PAGE_READWRITE; 69 | mapmode = FILE_MAP_WRITE; 70 | break; 71 | case 4: 72 | prot = PAGE_WRITECOPY; 73 | mapmode = FILE_MAP_COPY; 74 | break; 75 | default: 76 | return ((void *) -1); 77 | } 78 | 79 | mmaping = CreateFileMapping((HANDLE) fd, NULL, prot, 0, 0, NULL); 80 | 81 | if (mmaping == NULL) 82 | return ((void *) -1); 83 | 84 | result = MapViewOfFile(mmaping, mapmode, (DWORD) ((alignment >> 0x20) & 0x7fffffff), (DWORD) (alignment & 0xffffffff), (SIZE_T) (size & 0xffffffff)); 85 | CloseHandle(mmaping); 86 | 87 | return result; 88 | } 89 | 90 | void cMunmapPort(void *address, Int32 length) 91 | { 92 | UnmapViewOfFile((HANDLE) address); 93 | } 94 | 95 | -------------------------------------------------------------------------------- /dex/dex_driver.h: -------------------------------------------------------------------------------- 1 | /*@ 2 | XOC Release License 3 | 4 | Copyright (c) 2013-2014, Alibaba Group, All rights reserved. 5 | 6 | compiler@aliexpress.com 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | 11 | * Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | * Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | * Neither the name of the Su Zhenyu nor the names of its contributors 17 | may be used to endorse or promote products derived from this software 18 | without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 21 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS 24 | BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 26 | OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 27 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 30 | IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | author: Su Zhenyu 33 | @*/ 34 | #ifndef _DEX_DRIVER_H_ 35 | #define _DEX_DRIVER_H_ 36 | 37 | #ifdef __cplusplus 38 | extern "C" { 39 | #endif 40 | 41 | //Export Functions. 42 | bool compileFunc( 43 | RegionMgr * rumgr, 44 | D2Dpool * pool, 45 | LIRCode * fu, 46 | DexFile * df, 47 | DexMethod const* dm, 48 | DexCode const* dexcode, 49 | DexClassDef const* dexclassdef, 50 | OffsetVec const& offsetvec, 51 | List * rulist); 52 | 53 | #ifdef __cplusplus 54 | } 55 | #endif 56 | #endif 57 | 58 | -------------------------------------------------------------------------------- /opt/lt_prio_mgr.h: -------------------------------------------------------------------------------- 1 | /*@ 2 | Copyright (c) 2013-2021, Su Zhenyu steven.known@gmail.com 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the Su Zhenyu nor the names of its contributors 14 | may be used to endorse or promote products derived from this software 15 | without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED "AS IS" AND ANY 18 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 21 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 23 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 24 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 25 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 26 | USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | @*/ 28 | #ifndef _LT_PRIO_MGR_H_ 29 | #define _LT_PRIO_MGR_H_ 30 | 31 | namespace xoc { 32 | 33 | class LTPriorityMgr { 34 | COPY_CONSTRUCTOR(LTPriorityMgr); 35 | TargInfoMgr const& m_ti_mgr; 36 | IRCFG const* m_cfg; 37 | public: 38 | LTPriorityMgr(IRCFG const* cfg, TargInfoMgr const& timgr) : 39 | m_ti_mgr(timgr), m_cfg(cfg) {} 40 | 41 | double computePriority(LifeTime const* lt) const; 42 | void computePriority(LTList const& lst) const; 43 | void computePriority(LifeTimeMgr const& ltmgr) const 44 | { computePriority(ltmgr.getLTList()); } 45 | }; 46 | 47 | } //namespace xoc 48 | #endif 49 | -------------------------------------------------------------------------------- /opt/storage_space.h: -------------------------------------------------------------------------------- 1 | /*@ 2 | Copyright (c) 2013-2021, Su Zhenyu steven.known@gmail.com 3 | 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | * Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | * Neither the name of the Su Zhenyu nor the names of its contributors 15 | may be used to endorse or promote products derived from this software 16 | without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED "AS IS" AND ANY 19 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 22 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 25 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | @*/ 29 | #ifndef _STORAGE_SPACE_H_ 30 | #define _STORAGE_SPACE_H_ 31 | 32 | namespace xoc { 33 | 34 | //The storage space represents property for memory operations. 35 | typedef enum tagStorageSpace { 36 | SS_UNDEF = 0, 37 | SS_GLOBAL, 38 | SS_REG, 39 | SS_SPM, 40 | SS_PARAM, 41 | SS_SHARED, 42 | SS_STACK, 43 | SS_READONLY, 44 | SS_ANY, 45 | } StorageSpace; 46 | 47 | class StorageSpaceDesc { 48 | public: 49 | StorageSpace ss; 50 | CHAR const* name; 51 | public: 52 | //Get flag's name. 53 | static CHAR const* getName(StorageSpace ss); 54 | }; 55 | 56 | } //namespace xoc 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /elf/elf_targinfo.h: -------------------------------------------------------------------------------- 1 | /*@ 2 | Copyright (c) 2013-2021, Su Zhenyu steven.known@gmail.com 3 | 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | * Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | * Neither the name of the Su Zhenyu nor the names of its contributors 15 | may be used to endorse or promote products derived from this software 16 | without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED "AS IS" AND ANY 19 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 22 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 25 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | @*/ 29 | #ifndef _ELF_TARGINFO_H_ 30 | #define _ELF_TARGINFO_H_ 31 | 32 | namespace elf { 33 | 34 | class ELFMgr; 35 | 36 | class ELFTargInfo { 37 | ELFMgr * m_elf_mgr; 38 | public: 39 | ELFTargInfo(ELFMgr * mgr) { m_elf_mgr = mgr; } 40 | virtual ~ELFTargInfo() {} 41 | 42 | //Return the machine type. 43 | virtual CHAR const* getMachineTypeName() const; 44 | 45 | //Return the relocation type. 46 | //The function requires processor-specific information. 47 | //The ABI supplement for the specific processor describes the details. 48 | virtual CHAR const* getRelTypeName(Word r) const; 49 | }; 50 | 51 | } 52 | #endif 53 | -------------------------------------------------------------------------------- /opt/extend_type.cpp: -------------------------------------------------------------------------------- 1 | /*@ 2 | Copyright (c) 2013-2021, Su Zhenyu steven.known@gmail.com 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the Su Zhenyu nor the names of its contributors 14 | may be used to endorse or promote products derived from this software 15 | without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED "AS IS" AND ANY 18 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 21 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 23 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 24 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 25 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 26 | USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | @*/ 28 | #include "cominc.h" 29 | 30 | namespace xoc { 31 | 32 | // 33 | //START UINT128 34 | // 35 | CHAR const* UINT128::dump(OUT xcom::DefFixedStrBuf & buf) const 36 | { 37 | buf.sprint("0x%llx,0x%llx", m_low, m_high); 38 | return buf.getBuf(); 39 | } 40 | //END UINT128 41 | 42 | 43 | // 44 | //START INT128 45 | // 46 | INT128::INT128(UINT128 const& v) 47 | { 48 | m_low = v.m_low; 49 | m_high = v.m_high; 50 | } 51 | 52 | 53 | CHAR const* INT128::dump(OUT xcom::DefFixedStrBuf & buf) const 54 | { 55 | buf.sprint("0x%llx,0x%llx", m_low, m_high); 56 | return buf.getBuf(); 57 | } 58 | //END INT128 59 | 60 | } //namespace xoc 61 | -------------------------------------------------------------------------------- /dex/dex_cp.h: -------------------------------------------------------------------------------- 1 | /*@ 2 | XOC Release License 3 | 4 | Copyright (c) 2013-2014, Alibaba Group, All rights reserved. 5 | 6 | compiler@aliexpress.com 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | 11 | * Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | * Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | * Neither the name of the Su Zhenyu nor the names of its contributors 17 | may be used to endorse or promote products derived from this software 18 | without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 21 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS 24 | BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 26 | OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 27 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 30 | IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | author: Su Zhenyu 33 | @*/ 34 | #ifndef _DEX_CP_H_ 35 | #define _DEX_CP_H_ 36 | 37 | class DEX_CP : public CopyProp { 38 | public: 39 | DEX_CP(Region * rg) : CopyProp(rg) {} 40 | virtual ~DEX_CP() {} 41 | 42 | //Check if ir is appropriate for propagation. 43 | virtual bool canBeCandidate(IR const* ir) const 44 | { 45 | //Prop const imm may generate code which is not legal dex format. 46 | //TODO: Perform more code normalization before ir2dex. 47 | //return ir->is_const() || ir->is_pr(); 48 | 49 | return ir->is_pr(); 50 | } 51 | }; 52 | 53 | #endif 54 | --------------------------------------------------------------------------------