Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add TriCore Architecture #1973

Merged
merged 163 commits into from
May 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
163 commits
Select commit Hold shift + click to select a range
7449ebc
Add TriCore Architecture
sidneyp May 15, 2016
6374a77
Modify Makefiles for TriCore architecture
sidneyp May 21, 2016
adbe3f2
Fix Disassembler and TableGen Files of TriCore
sidneyp May 26, 2016
b53a820
Map instruction and fix part of InstPrinter
sidneyp May 27, 2016
e9ccee6
Improve TriCore InstPrinter and Mapping
sidneyp Jun 10, 2016
6274036
Fix TriCore GenAsmWriter and InstPrinter
sidneyp Jun 12, 2016
a351c48
Add group name maps
sidneyp Jul 16, 2016
f6fb321
Fix error of undeclared instructions and registers
sidneyp Jul 27, 2016
48d77e7
Fix all errors in TriCoreDisassembler
sidneyp Aug 4, 2016
76b0f17
Fix all errors in TriCoreInstPrinter
sidneyp Aug 4, 2016
c1c1634
Fix all compiler errors
sidneyp Aug 4, 2016
82fcf25
Remove all compiler warnings
sidneyp Aug 6, 2016
8a07047
Fix printing MemSrc
sidneyp Sep 4, 2016
d026a80
Adjust printing of Registers and upgrade TriCore test
sidneyp Sep 5, 2016
238a96d
Transfer modifications of TriDis/llvm-tricore on Sep 20, 2016
sidneyp Sep 22, 2016
87f935d
Transfer modifications of TriDis/llvm-tricore on Oct 05, 2016
sidneyp Oct 5, 2016
6fdc21b
Fix memory access printing and clean unused functions
sidneyp Oct 6, 2016
1a5d594
Adjustments in TriCore and add more instructions into tests/test_tric…
sidneyp Oct 8, 2016
83980f6
Fix TriCore Mapping
sidneyp Nov 6, 2016
6f24f0c
Fix TriCore register mapping
sidneyp Nov 6, 2016
59e9494
Add document with available TriCore instructions.
sidneyp Jan 8, 2017
dfd368f
Transfer modifications of TriDis/llvm-tricore on Feb, 04 2017
sidneyp Feb 5, 2017
f743c6c
Update document with newly available TriCore instructions
sidneyp Feb 5, 2017
6b4d731
Fix rebase error
imbillow Mar 3, 2023
c6138ac
Fix build and test
imbillow Mar 3, 2023
775dbc7
fix arch_configs[CS_ARCH_TRICORE]
imbillow Mar 10, 2023
1327536
add TriCore tablegen files
imbillow Mar 15, 2023
273e655
add `ABS`
imbillow Mar 16, 2023
86be2a4
add more `ADD`
imbillow Mar 15, 2023
4535b7c
Add more multiclass
imbillow Mar 16, 2023
e3c5b13
add more `ADD`
imbillow Mar 20, 2023
4a0e3c5
add `AND`
imbillow Mar 20, 2023
cf426c6
add `cache` inst
imbillow Mar 20, 2023
36cd297
add `cadd`
imbillow Mar 20, 2023
28766e1
add:
imbillow Mar 20, 2023
719a312
add:
imbillow Mar 20, 2023
8885ab1
Changes to be committed:
imbillow Mar 21, 2023
d1c2bfc
modified: arch/TriCore/TriCoreInstrInfo.td
imbillow Mar 21, 2023
c1fdc02
`ld*`
imbillow Mar 22, 2023
5942664
- `LD*`
imbillow Mar 22, 2023
6afa9d2
`MADD*`
imbillow Mar 22, 2023
b054d03
fix `MADD*`
imbillow Mar 22, 2023
a83127c
`MAX*` `MFCR` `MIN*`
imbillow Mar 22, 2023
5e56b34
`MOV*`
imbillow Mar 22, 2023
b836f20
`MSUB*`
imbillow Mar 22, 2023
592ecce
`MUL*` `NAND*` `NE*` `NOP` `NOR` `OR`
imbillow Mar 23, 2023
033f1e7
modified: arch/TriCore/TriCoreInstrInfo.td
imbillow Mar 23, 2023
07e762b
RSUB* SAT* SEL* SH*
imbillow Mar 23, 2023
a128774
SHA* ST*
imbillow Mar 23, 2023
3260d43
ST SUB SYSCALL XOR XNOR
imbillow Mar 23, 2023
abf826a
update `TriCore*.inc`
imbillow Mar 23, 2023
655a8ba
add FPU Instructions
imbillow Mar 23, 2023
c776b8c
fix build
imbillow Mar 23, 2023
bdeb9ee
`Decode*Instruction`
imbillow Mar 24, 2023
29d57ee
fix `DecodeInstruction`
imbillow Mar 24, 2023
b8ede53
add `tricore` to `cstool`
imbillow Mar 24, 2023
d522758
add `tricore` to `cstest`
imbillow Mar 24, 2023
cfea930
fix
imbillow Mar 24, 2023
ede95ff
fix
imbillow Mar 25, 2023
8fc6ecc
- add `tricore` to python binding
imbillow Mar 25, 2023
b6b2777
add more `tricore` cstest
imbillow Mar 25, 2023
c63f41d
add `sign_ext` `zero_ext`
imbillow Mar 25, 2023
47ccaaf
fix
imbillow Mar 25, 2023
8a3ba2d
fix `DecodeRegisterClass`
imbillow Mar 26, 2023
f069589
fix `DecodeRegisterClass`
imbillow Mar 26, 2023
fbc85a0
fix `BO` `BOL`
imbillow Mar 26, 2023
e69b18b
fix `SRRS`
imbillow Mar 26, 2023
9fb9765
fix
imbillow Mar 26, 2023
fccf575
fix `RRPW`
imbillow Mar 26, 2023
1ccb9a6
fix `INSERT_rrpw`
imbillow Mar 26, 2023
cba2891
fix `RR`
imbillow Mar 26, 2023
18954aa
fix
imbillow Mar 26, 2023
eefd54f
fix `mov.a` `mov.d`
imbillow Mar 26, 2023
a5ce9b6
fix `imask`
imbillow Mar 26, 2023
e456240
Whether to call `a10` a `sp`
imbillow Mar 26, 2023
7eff029
add `MTCR`
imbillow Mar 26, 2023
f657e1a
add `BO`
imbillow Mar 26, 2023
2ace396
docs: Refactor project structure and remove unnecessary file.
imbillow Mar 27, 2023
9fff040
fix: TriCore architecture disassembly codes
imbillow Mar 27, 2023
7fccdd2
fix: TriCore instruction decoding and printing.
imbillow Mar 27, 2023
8eee760
fix: decode error
imbillow Mar 28, 2023
8b4f448
Fix: TriCore instruction operations and decoding.
imbillow Mar 28, 2023
d2f4d19
fix: TriCore Instruction Formats and Printing
imbillow Mar 28, 2023
38da82c
refactor: Refactor TriCore instructions and operands
imbillow Mar 29, 2023
22feb62
feat: Fix bugs and update instructions for TriCore architecture.
imbillow Mar 29, 2023
ffa7c98
fix: decode `j` `call` `loop`
imbillow Mar 29, 2023
bb86641
unique tests
imbillow Mar 29, 2023
2d74f34
fix: `disp` print and fill
imbillow Mar 31, 2023
1474f1e
just add TriCoreISA enum
imbillow Mar 31, 2023
f0ca9dc
add tricore Predicates
imbillow Apr 1, 2023
40031c4
cleanup
imbillow Apr 1, 2023
b1f77e4
add some tricore v1.1 inst
imbillow Apr 1, 2023
e48168a
fix `cachea`
imbillow Apr 1, 2023
27c31c1
refactor: Refactor TriCore register names.
imbillow Apr 1, 2023
a8153b4
refactor: Improve TriCore instruction handling.
imbillow Apr 2, 2023
a75e4db
refactor: Add support for new TriCore instructions and constraints.
imbillow Apr 2, 2023
117c9eb
refactor: Update TriCore instruction requirements
imbillow Apr 3, 2023
29ced4e
refactor: Refactor TriCore instruction decoding and register definition.
imbillow Apr 3, 2023
0aeed24
add `tricore_feature` support
imbillow Apr 4, 2023
072b70f
feat: Add and remove TriCore instructions.
imbillow Apr 4, 2023
88d5027
refactor: Add new TriCore instructions and remove deprecated ones.
imbillow Apr 5, 2023
50483a2
refactor: Refactor TriCore instruction definitions and mappings
imbillow Apr 6, 2023
963b7ad
refactor: Improve Architecture Instruction Information.
imbillow Apr 6, 2023
f035d04
refactor: Refactor TriCore instruction classes and operands
imbillow Apr 6, 2023
abf1b46
Optimize TriCore instruction information.
imbillow Apr 6, 2023
e579032
Optimize TriCore instruction information.
imbillow Apr 6, 2023
bdc4aa4
refactor: Improve TriCore instruction definitions in architecture file
imbillow Apr 6, 2023
d3163a6
refactor: Improve instruction handling for TriCore architecture
imbillow Apr 6, 2023
4409b29
Add support for TriCore V162 and new instructions/operands.
imbillow Apr 6, 2023
4b3f284
Refactor: Optimize TriCore instruction information.
imbillow Apr 6, 2023
443af68
refactor: Improve TriCore floating-point operations in instruction set
imbillow Apr 7, 2023
d59e012
refactor: Optimize TriCore instructions in arch/TriCore/TriCoreInstrI…
imbillow Apr 7, 2023
b9151fb
fix
imbillow Apr 7, 2023
7c56b54
feat: Add support for TriCore feature bits and new architectures
imbillow Apr 7, 2023
98c1a24
feat: Refactor and improve triCore platform support
imbillow Apr 7, 2023
7200d39
feat: Update TriCore processor support and architecture modes
imbillow Apr 7, 2023
463a8df
fix
imbillow Apr 7, 2023
587279f
add some tc162 tests
imbillow Apr 7, 2023
c1c4137
fix TriCoreDisassembler.c from tests
imbillow Apr 8, 2023
bd8b7da
fix tricore tests
imbillow Apr 8, 2023
b4820f2
feat: Update Tricore assembly code and disassembler logic.
imbillow Apr 8, 2023
73810e1
add tc110 tests and fix tricore decode
imbillow Apr 8, 2023
3b11b2d
fix `CADD` `CSUB`
imbillow Apr 8, 2023
9939c86
fix tc110 test and fix decode
imbillow Apr 8, 2023
8dd3ae1
fix `RCR` printer
imbillow Apr 8, 2023
95ffda7
fix
imbillow Apr 8, 2023
ff0c69f
fix
imbillow Apr 8, 2023
f0cfb4d
fix
imbillow Apr 8, 2023
42ce4f2
fix tc1.1 tests
imbillow Apr 8, 2023
a93ace5
fix tc1.6.2 tests
imbillow Apr 8, 2023
9c982d3
fix tc1.6.2 tests
imbillow Apr 8, 2023
4d9d539
add tests
imbillow Apr 8, 2023
9bf0041
Update TriCore instructions in TriCoreInstrInfo.td
imbillow Apr 8, 2023
5417985
fix tests
imbillow Apr 9, 2023
6b334f8
fix tests
imbillow Apr 9, 2023
2814baa
fix tests
imbillow Apr 9, 2023
5af4475
fix `TRICORE_GENERIC` inst
imbillow Apr 9, 2023
2de47c4
fix tests
imbillow Apr 9, 2023
f8ad73b
fix `TriCore_getRegisterName`
imbillow Apr 9, 2023
cb8e351
cleanup
imbillow Apr 9, 2023
80ce512
fix `TRICORE_OP_MEM`
imbillow Apr 9, 2023
a7581ac
fix `TriCoreGenCSMappingInsnName.inc`
imbillow Apr 10, 2023
5260fbe
Update tricore `.inc`
imbillow Apr 10, 2023
4033ff0
fix `test_corpus.py`
imbillow Apr 10, 2023
926714c
fix fuzz
imbillow Apr 10, 2023
37647a2
fix fuzz
imbillow Apr 10, 2023
4ebad28
update TriCoreGenAsmWriter.inc
imbillow Apr 13, 2023
878883a
add TriCore in README
imbillow Apr 14, 2023
d9f13fe
fix tricore endian
imbillow Apr 17, 2023
37bc4e8
fix: support for TriCore call group mapping
imbillow Apr 20, 2023
d88124b
fix all tricore compile warnings
imbillow Apr 20, 2023
58bce36
Format all .(c|h) code
imbillow Apr 20, 2023
18f82fc
Fix format error
imbillow Apr 23, 2023
4bc115f
Fix `print_insn_detail_tricore` and disp fill
imbillow Apr 23, 2023
9e15c96
Fix tricore python binding
imbillow Apr 24, 2023
010acad
Fix HACK.TXT
imbillow Apr 24, 2023
1ed507b
Fix tricore.h and remove `inc` folder
imbillow Apr 25, 2023
4d693da
Fix tricore.h
imbillow Apr 26, 2023
620f0d0
Merge branch 'next' into tricore
imbillow Apr 27, 2023
985b6fc
Upper all `inc` and fix
imbillow May 1, 2023
588a3e1
Upper tricore_const.py
imbillow May 1, 2023
a1c3b63
Update suite/test_corpus3.py
imbillow May 1, 2023
a658d37
Merge branch 'next' into tricore
imbillow May 2, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ tests/test_skipdata
tests/test_sparc
tests/test_systemz
tests/test_xcore
tests/test_tricore
tests/*.static
tests/test_customized_mnem
tests/test_m68k
Expand Down
50 changes: 47 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,14 @@ option(CAPSTONE_BUILD_STATIC_RUNTIME "Embed static runtime" ${BUILD_SHARED_LIBS}
option(CAPSTONE_BUILD_DIET "Build diet library" OFF)
option(CAPSTONE_BUILD_TESTS "Build tests" ${PROJECT_IS_TOP_LEVEL})
option(CAPSTONE_BUILD_CSTOOL "Build cstool" ${PROJECT_IS_TOP_LEVEL})
option(CAPSTONE_BUILD_CSTEST "Build cstest" OFF)
option(CAPSTONE_USE_DEFAULT_ALLOC "Use default memory allocation functions" ON)
option(CAPSTONE_ARCHITECTURE_DEFAULT "Whether architectures are enabled by default" ON)
option(CAPSTONE_DEBUG "Whether to enable extra debug assertions" OFF)
option(CAPSTONE_INSTALL "Generate install target" ${PROJECT_IS_TOP_LEVEL})

set(SUPPORTED_ARCHITECTURES ARM ARM64 M68K MIPS PPC SPARC SYSZ XCORE X86 TMS320C64X M680X EVM MOS65XX WASM BPF RISCV SH)
set(SUPPORTED_ARCHITECTURE_LABELS ARM ARM64 M68K MIPS PowerPC Sparc SystemZ XCore x86 TMS320C64x M680x EVM MOS65XX WASM BPF RISCV SH)
set(SUPPORTED_ARCHITECTURES ARM ARM64 M68K MIPS PPC SPARC SYSZ XCORE X86 TMS320C64X M680X EVM MOS65XX WASM BPF RISCV SH TRICORE)
set(SUPPORTED_ARCHITECTURE_LABELS ARM ARM64 M68K MIPS PowerPC Sparc SystemZ XCore x86 TMS320C64x M680x EVM MOS65XX WASM BPF RISCV SH TriCore)

list(LENGTH SUPPORTED_ARCHITECTURES count)
math(EXPR count "${count}-1")
Expand Down Expand Up @@ -135,6 +136,7 @@ set(HEADERS_COMMON
include/capstone/bpf.h
include/capstone/riscv.h
include/capstone/sh.h
include/capstone/tricore.h
include/capstone/platform.h
)

Expand Down Expand Up @@ -533,7 +535,28 @@ if(CAPSTONE_SH_SUPPORT)
set(TEST_SOURCES ${TEST_SOURCES} test_sh.c)
endif()

if(CAPSTONE_OSXKERNEL_SUPPORT)
if (CAPSTONE_TRICORE_SUPPORT)
add_definitions(-DCAPSTONE_HAS_TRICORE)
set(SOURCES_TRICORE
arch/TriCore/TriCoreDisassembler.c
arch/TriCore/TriCoreInstPrinter.c
arch/TriCore/TriCoreMapping.c
arch/TriCore/TriCoreModule.c
)
set(HEADERS_TRICORE
arch/TriCore/TriCoreDisassembler.h
arch/TriCore/TriCoreGenAsmWriter.inc
arch/TriCore/TriCoreGenDisassemblerTables.inc
arch/TriCore/TriCoreGenInstrInfo.inc
arch/TriCore/TriCoreGenRegisterInfo.inc
arch/TriCore/TriCoreInstPrinter.h
arch/TriCore/TriCoreMapping.h
arch/TriCore/TriCoreModule.h
)
set(TEST_SOURCES ${TEST_SOURCES} test_tricore.c)
endif ()

if (CAPSTONE_OSXKERNEL_SUPPORT)
add_definitions(-DCAPSTONE_HAS_OSXKERNEL)
endif()

Expand All @@ -556,6 +579,7 @@ set(ALL_SOURCES
${SOURCES_BPF}
${SOURCES_RISCV}
${SOURCES_SH}
${SOURCES_TRICORE}
)

set(ALL_HEADERS
Expand All @@ -578,6 +602,7 @@ set(ALL_HEADERS
${HEADERS_BPF}
${HEADERS_RISCV}
${HEADERS_SH}
${HEADERS_TRICORE}
)

## properties
Expand Down Expand Up @@ -640,6 +665,7 @@ source_group("Source\\MOS65XX" FILES ${SOURCES_MOS65XX})
source_group("Source\\BPF" FILES ${SOURCES_BPF})
source_group("Source\\RISCV" FILES ${SOURCES_RISCV})
source_group("Source\\SH" FILES ${SOURCES_SH})
source_group("Source\\TriCore" FILES ${SOURCES_TRICORE})

source_group("Include\\Common" FILES ${HEADERS_COMMON})
source_group("Include\\Engine" FILES ${HEADERS_ENGINE})
Expand All @@ -660,6 +686,7 @@ source_group("Include\\MOS65XX" FILES ${HEADERS_MOS65XX})
source_group("Include\\BPF" FILES ${HEADERS_BPF})
source_group("Include\\RISCV" FILES ${HEADERS_RISCV})
source_group("Include\\SH" FILES ${HEADERS_SH})
source_group("Include\\TriCore" FILES ${HEADERS_TRICORE})

## installation
if(CAPSTONE_INSTALL)
Expand Down Expand Up @@ -726,3 +753,20 @@ if(CAPSTONE_BUILD_CSTOOL)
install(TARGETS cstool EXPORT capstone-targets DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()
endif()

if(CAPSTONE_BUILD_CSTEST)
find_package(CMOCKA)

file(GLOB CSTEST_SRC suite/cstest/src/*.c)
add_executable(cstest ${CSTEST_SRC})
target_link_libraries(cstest PUBLIC capstone ${CMOCKA_LIBRARIES})
target_include_directories(cstest PRIVATE
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
${PROJECT_SOURCE_DIR}/suite/cstest/include
${CMOCKA_INCLUDE_DIR}
)

if(CAPSTONE_INSTALL)
install(TARGETS cstest EXPORT capstone-targets DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()
endif()
1 change: 1 addition & 0 deletions COMPILE.TXT
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ Capstone requires no prerequisite packages, so it is easy to compile & install.
/usr/include/capstone/wasm.h
/usr/include/capstone/x86.h
/usr/include/capstone/xcore.h
/usr/include/capstone/tricore.h
/usr/lib/libcapstone.a
/usr/lib/libcapstone.so (for Linux/*nix), or /usr/lib/libcapstone.dylib (OSX)

Expand Down
1 change: 1 addition & 0 deletions COMPILE_CMAKE.TXT
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Get CMake for free from http://www.cmake.org.
- CAPSTONE_SPARC_SUPPORT: support Sparc. Run cmake with -DCAPSTONE_SPARC_SUPPORT=0 to remove Sparc.
- CAPSTONE_SYSZ_SUPPORT: support SystemZ. Run cmake with -DCAPSTONE_SYSZ_SUPPORT=0 to remove SystemZ.
- CAPSTONE_XCORE_SUPPORT: support XCore. Run cmake with -DCAPSTONE_XCORE_SUPPORT=0 to remove XCore.
- CAPSTONE_TRICORE_SUPPORT: support TriCore. Run cmake with -DCAPSTONE_TRICORE_SUPPORT=0 to remove TriCore.
- CAPSTONE_X86_SUPPORT: support X86. Run cmake with -DCAPSTONE_X86_SUPPORT=0 to remove X86.
- CAPSTONE_X86_TMS320C64X: support TMS320C64X. Run cmake with -DCAPSTONE_TMS320C64X_SUPPORT=0 to remove TMS320C64X.
- CAPSTONE_X86_M680X: support M680X. Run cmake with -DCAPSTONE_M680X_SUPPORT=0 to remove M680X.
Expand Down
1 change: 1 addition & 0 deletions COMPILE_MSVC.TXT
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ versions, and Windows Driver Kit 8.1 Update 1 or newer versions are required.
- CAPSTONE_HAS_SYSZ: support SystemZ. Delete this to remove SystemZ support.
- CAPSTONE_HAS_X86: support X86. Delete this to remove X86 support.
- CAPSTONE_HAS_XCORE: support XCore. Delete this to remove XCore support.
- CAPSTONE_HAS_TRICORE: support TriCore. Delete this to remove TriCore support.

By default, all 9 architectures are compiled in.

Expand Down
1 change: 1 addition & 0 deletions CREDITS.TXT
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,4 @@ david942j: BPF (both classic and extended) architecture.
fanfuqiang & citypw & porto703 : RISCV architecture.
Josh "blacktop" Maine: Arm64 architecture improvements.
Finn Wilkinson: AArch64 update to Armv9.2-a (SME + SVE2 support)
Billow & Sidneyp : TriCore architecture.
8 changes: 5 additions & 3 deletions HACK.TXT
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ Capstone source is organized as followings.
│   ├── Mips <- Mips engine
│   ├── MOS65XX <- MOS65XX engine
│   ├── PowerPC <- PowerPC engine
│   ├── RISCV <- RISCV engine
│   ├── SH <- SH engine
│   ├── Sparc <- Sparc engine
│   ├── SystemZ <- SystemZ engine
│   ├── TMS320C64x <- TMS320C64x engine
│   ├── X86 <- X86 engine
│   └── XCore <- XCore engine
│   ├── TriCore <- TriCore engine
│   └── WASM <- WASM engine
├── bindings <- all bindings are under this dir
│   ├── java <- Java bindings + test code
│   ├── ocaml <- Ocaml bindings + test code
Expand Down Expand Up @@ -85,7 +87,7 @@ Tests:
- tests/test_detail.c
- tests/test_iter.c
- tests/test_newarch.c
- suite/fuzz/fuzz_disasm.c: add the architecture and its modes to the list of fuzzed platforms
- suite/fuzz/platform.c: add the architecture and its modes to the list of fuzzed platforms
- suite/capstone_get_setup.c
- suite/MC/newarch/mode.mc: samples
- suite/test_corpus.py: correspondence between architecture and mode as text and architecture number for fuzzing
Expand Down
6 changes: 5 additions & 1 deletion MCInstrDesc.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,11 @@ enum MCOI_OperandType {
MCOI_OPERAND_GENERIC_5 = 11,
MCOI_OPERAND_LAST_GENERIC = 11,

MCOI_OPERAND_FIRST_TARGET = 12,
MCOI_OPERAND_FIRST_GENERIC_IMM = 12,
MCOI_OPERAND_GENERIC_IMM_0 = 12,
MCOI_OPERAND_LAST_GENERIC_IMM = 12,

MCOI_OPERAND_FIRST_TARGET = 13,
};


Expand Down
14 changes: 13 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -314,11 +314,22 @@ ifneq (,$(findstring bpf,$(CAPSTONE_ARCHS)))
LIBOBJ_BPF += $(LIBSRC_BPF:%.c=$(OBJDIR)/%.o)
endif

DEP_TRICORE =
DEP_TRICORE +=$(wildcard arch/TriCore/TriCore*.inc)

LIBOBJ_TRICORE =
ifneq (,$(findstring tricore,$(CAPSTONE_ARCHS)))
CFLAGS += -DCAPSTONE_HAS_TRICORE
LIBSRC_TRICORE += $(wildcard arch/TriCore/TriCore*.c)
LIBOBJ_TRICORE += $(LIBSRC_TRICORE:%.c=$(OBJDIR)/%.o)
endif


LIBOBJ =
LIBOBJ += $(OBJDIR)/cs.o $(OBJDIR)/utils.o $(OBJDIR)/SStream.o $(OBJDIR)/MCInstrDesc.o $(OBJDIR)/MCRegisterInfo.o
LIBOBJ += $(LIBOBJ_ARM) $(LIBOBJ_ARM64) $(LIBOBJ_M68K) $(LIBOBJ_MIPS) $(LIBOBJ_PPC) $(LIBOBJ_RISCV) $(LIBOBJ_SPARC) $(LIBOBJ_SYSZ) $(LIBOBJ_SH)
LIBOBJ += $(LIBOBJ_X86) $(LIBOBJ_XCORE) $(LIBOBJ_TMS320C64X) $(LIBOBJ_M680X) $(LIBOBJ_EVM) $(LIBOBJ_MOS65XX) $(LIBOBJ_WASM) $(LIBOBJ_BPF)
LIBOBJ += $(LIBOBJ_TRICORE)
LIBOBJ += $(OBJDIR)/MCInst.o


Expand Down Expand Up @@ -454,6 +465,7 @@ $(LIBOBJ_RISCV): $(DEP_RISCV)
$(LIBOBJ_WASM): $(DEP_WASM)
$(LIBOBJ_MOS65XX): $(DEP_MOS65XX)
$(LIBOBJ_BPF): $(DEP_BPF)
$(LIBOBJ_TRICORE): $(DEP_TRICORE)

ifeq ($(CAPSTONE_STATIC),yes)
$(ARCHIVE): $(LIBOBJ)
Expand Down Expand Up @@ -539,7 +551,7 @@ dist:
git archive --format=tar.gz --prefix=capstone-$(DIST_VERSION)/ $(TAG) > capstone-$(DIST_VERSION).tgz
git archive --format=zip --prefix=capstone-$(DIST_VERSION)/ $(TAG) > capstone-$(DIST_VERSION).zip

TESTS = test_basic test_detail test_arm test_arm64 test_m68k test_mips test_ppc test_sparc
TESTS = test_basic test_detail test_arm test_arm64 test_m68k test_mips test_ppc test_sparc test_tricore
TESTS += test_systemz test_x86 test_xcore test_iter test_evm test_riscv test_mos65xx test_wasm test_bpf
TESTS += test_basic.static test_detail.static test_arm.static test_arm64.static
TESTS += test_m68k.static test_mips.static test_ppc.static test_sparc.static
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Capstone offers some unparalleled features:

- Support multiple hardware architectures: ARM, ARM64 (ARMv8), BPF, Ethereum VM,
M68K, M680X, Mips, MOS65XX, PPC, RISC-V(rv32G/rv64G), SH, Sparc, SystemZ,
TMS320C64X, Webassembly, XCore and X86 (16, 32, 64).
TMS320C64X, TriCore, Webassembly, XCore and X86 (16, 32, 64).

- Having clean/simple/lightweight/intuitive architecture-neutral API.

Expand Down
134 changes: 134 additions & 0 deletions arch/TriCore/TriCore.td
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
//===-- TriCore.td - Describe the TriCore Target Machine ---*- tablegen -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This is the top level entry point for the TriCore target.
//
//===----------------------------------------------------------------------===//

//===----------------------------------------------------------------------===//
// Target-independent interfaces which we are implementing
//===----------------------------------------------------------------------===//

include "llvm/Target/Target.td"

//===----------------------------------------------------------------------===//
// Descriptions
//===----------------------------------------------------------------------===//

// Specify whether target support specific TRICORE ISA variants.

def HasV110Ops : SubtargetFeature<"v1.1", "HasV110Ops", "true",
"Support TriCore v1.1 instructions",
[]>;
def HasV120Ops : SubtargetFeature<"v1.2", "HasV120Ops", "true",
"Support TriCore v1.2 instructions",
[]>;
def HasV130Ops : SubtargetFeature<"v1.3", "HasV130Ops", "true",
"Support TriCore v1.3 instructions",
[]>;
def HasV131Ops : SubtargetFeature<"v1.3.1", "HasV131Ops", "true",
"Support TriCore v1.3.1 instructions",
[]>;
def HasV160Ops : SubtargetFeature<"v1.6", "HasV160Ops", "true",
"Support TriCore v1.6 instructions",
[]>;
def HasV161Ops : SubtargetFeature<"v1.6.1", "HasV161Ops", "true",
"Support TriCore v1.6.1 instructions",
[]>;
def HasV162Ops : SubtargetFeature<"v1.6.2", "HasV162Ops", "true",
"Support TriCore v1.6.2 instructions",
[]>;

def HasV110 : Predicate<"HasV120Ops()">, AssemblerPredicate<(all_of HasV110Ops), "v1.1">;
def HasV120 : Predicate<"HasV120Ops()">, AssemblerPredicate<(all_of HasV120Ops), "v1.2">;
def HasV130 : Predicate<"HasV130Ops()">, AssemblerPredicate<(all_of HasV130Ops), "v1.3">;
def HasV131 : Predicate<"HasV131Ops()">, AssemblerPredicate<(all_of HasV131Ops), "v1.3.1">;
def HasV160 : Predicate<"HasV160Ops()">, AssemblerPredicate<(all_of HasV160Ops), "v1.6">;
def HasV161 : Predicate<"HasV161Ops()">, AssemblerPredicate<(all_of HasV161Ops), "v1.6.1">;
def HasV162 : Predicate<"HasV162Ops()">, AssemblerPredicate<(all_of HasV162Ops), "v1.6.2">;

def HasV120_UP : Predicate<"HasV120Ops() || HasV130Ops() || HasV131Ops() || HasV160Ops() || HasV161Ops() || HasV162Ops()">
, AssemblerPredicate<(any_of HasV120Ops, HasV130Ops, HasV131Ops, HasV160Ops, HasV161Ops, HasV162Ops), "v120up">;
def HasV130_UP : Predicate<"HasV130Ops() || HasV131Ops() || HasV160Ops() || HasV161Ops() || HasV162Ops()">
, AssemblerPredicate<(any_of HasV130Ops, HasV131Ops, HasV160Ops, HasV161Ops, HasV162Ops), "v130up">;
def HasV131_UP : Predicate<"HasV131Ops() || HasV160Ops() || HasV161Ops() || HasV162Ops()">
, AssemblerPredicate<(any_of HasV131Ops, HasV160Ops, HasV161Ops, HasV162Ops), "v131up">;
def HasV160_UP : Predicate<"HasV160Ops() || HasV161Ops() || HasV162Ops()">
, AssemblerPredicate<(any_of HasV160Ops, HasV161Ops, HasV162Ops), "v160up">;
def HasV161_UP : Predicate<"HasV161Ops() || HasV162Ops()">
, AssemblerPredicate<(any_of HasV161Ops, HasV162Ops), "v161up">;
def HasV162_UP : Predicate<"HasV162Ops()">
, AssemblerPredicate<(any_of HasV162Ops), "v162up">;

def HasV120_DN : Predicate<"HasV120Ops() || HasV110Ops()">,
AssemblerPredicate<(any_of HasV120Ops, HasV110Ops), "v120dn">;
def HasV130_DN : Predicate<"HasV130Ops() || HasV120Ops() || HasV110Ops()">,
AssemblerPredicate<(any_of HasV130Ops, HasV120Ops, HasV110Ops), "v130dn">;
def HasV131_DN : Predicate<"HasV131Ops() || HasV130Ops() || HasV120Ops() || HasV110Ops()">,
AssemblerPredicate<(any_of HasV131Ops, HasV130Ops, HasV120Ops, HasV110Ops), "v131dn">;
def HasV160_DN : Predicate<"HasV160Ops() || HasV131Ops() || HasV130Ops() || HasV120Ops() || HasV110Ops()">,
AssemblerPredicate<(any_of HasV160Ops, HasV131Ops, HasV130Ops, HasV120Ops, HasV110Ops), "v160dn">;
def HasV161_DN : Predicate<"HasV161Ops() || HasV160Ops() || HasV131Ops() || HasV130Ops() || HasV120Ops() || HasV110Ops()">,
AssemblerPredicate<(any_of HasV161Ops, HasV160Ops, HasV131Ops, HasV130Ops, HasV120Ops, HasV110Ops), "v161dn">;
def HasV162_DN : Predicate<"HasV162Ops() || HasV161Ops() || HasV160Ops() || HasV131Ops() || HasV130Ops() || HasV120Ops() || HasV110Ops()">,
AssemblerPredicate<(any_of HasV162Ops, HasV161Ops, HasV160Ops, HasV131Ops, HasV130Ops, HasV120Ops, HasV110Ops), "v162dn">;


class Architecture<string fname, string aname, list<SubtargetFeature> features = []>
: SubtargetFeature<fname, "TriCoreArch", aname,
!strconcat(aname, " architecture"), features>;

class ProcNoItin<string Name, list<SubtargetFeature> Features>
: Processor<Name, NoItineraries, Features>;


def TRICORE_V1_1 : Architecture<"tricore-v1.1", "TRICOREv110", [HasV110Ops]>;
def TRICORE_V1_2 : Architecture<"tricore-V1.2", "TRICOREv120", [HasV120Ops]>;
def TRICORE_V1_3 : Architecture<"tricore-V1.3", "TRICOREv130", [HasV130Ops]>;
def TRICORE_V1_3_1 : Architecture<"tricore-V1.3.1", "TRICOREv131", [HasV131Ops]>;
def TRICORE_V1_6 : Architecture<"tricore-V1.6", "TRICOREv160", [HasV160Ops]>;
def TRICORE_V1_6_1 : Architecture<"tricore-V1.6.1", "TRICOREv161", [HasV161Ops]>;
def TRICORE_V1_6_2 : Architecture<"tricore-V1.6.2", "TRICOREv162", [HasV162Ops]>;
def TRICORE_PCP : Architecture<"tricore-PCP", "TRICOREpcp">;
def TRICORE_PCP2 : Architecture<"tricore-PCP2", "TRICOREpcp2">;

def TRICORE_RIDER_A : Architecture<"tricore-rider-a", "TRICOREv110", [TRICORE_V1_1]>;


include "TriCoreRegisterInfo.td"
include "TriCoreInstrInfo.td"
include "TriCoreCallingConv.td"

//===----------------------------------------------------------------------===//
// TriCore processors supported.
//===----------------------------------------------------------------------===//

def : ProcNoItin<"tc1796", [TRICORE_V1_3]>;
def : ProcNoItin<"tc1797", [TRICORE_V1_3_1]>;
def : ProcNoItin<"tc27x", [TRICORE_V1_6_1]>;
def : ProcNoItin<"tc161", [TRICORE_V1_6_1]>;
def : ProcNoItin<"tc162", [TRICORE_V1_6_2]>;
def : ProcNoItin<"tc16", [TRICORE_V1_6]>;
def : ProcNoItin<"tc131", [TRICORE_V1_3_1]>;
def : ProcNoItin<"tc13", [TRICORE_V1_3]>;

def TriCoreAsmWriter : AsmWriter {
int PassSubtarget = 1;
}

def TriCoreInstrInfo : InstrInfo;

//===----------------------------------------------------------------------===//
// Declare the target which we are implementing
//===----------------------------------------------------------------------===//

def TriCore : Target {
let InstructionSet = TriCoreInstrInfo;
let AssemblyWriters = [TriCoreAsmWriter];
}
Loading