From e260b036866572847c89a059cc4ee54b59c11d73 Mon Sep 17 00:00:00 2001 From: seyko Date: Tue, 6 Jan 2015 22:59:19 +0300 Subject: [PATCH] Allow tcc to understand a setob,... opcodes as alias to seto,... PS: http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20101122/112576.html This is fix PR8686 for llvm: accepting a 'b' suffix at the end of all the setcc instructions. --- i386-asm.h | 1 + i386-tok.h | 7 +++--- tcc.h | 62 ++++++++++++++++++++++++------------------------- tests/asmtest.S | 2 ++ x86_64-asm.h | 1 + 5 files changed, 39 insertions(+), 34 deletions(-) diff --git a/i386-asm.h b/i386-asm.h index a954afb0..43c88679 100644 --- a/i386-asm.h +++ b/i386-asm.h @@ -219,6 +219,7 @@ ALT(DEF_ASM_OP1(ljmp, 0xff, 5, 0, OPT_EA)) ALT(DEF_ASM_OP1(int, 0xcd, 0, 0, OPT_IM8)) ALT(DEF_ASM_OP1(seto, 0x0f90, 0, OPC_MODRM | OPC_TEST, OPT_REG8 | OPT_EA)) +ALT(DEF_ASM_OP1(setob, 0x0f90, 0, OPC_MODRM | OPC_TEST, OPT_REG8 | OPT_EA)) DEF_ASM_OP2(enter, 0xc8, 0, 0, OPT_IM16, OPT_IM8) DEF_ASM_OP0(leave, 0xc9) DEF_ASM_OP0(ret, 0xc3) diff --git a/i386-tok.h b/i386-tok.h index 6ba865d6..b0ca3edb 100644 --- a/i386-tok.h +++ b/i386-tok.h @@ -172,10 +172,11 @@ DEF_ASM(lcall) DEF_ASM(ljmp) - DEF_ASMTEST(j) + DEF_ASMTEST(j,) - DEF_ASMTEST(set) - DEF_ASMTEST(cmov) + DEF_ASMTEST(set,) + DEF_ASMTEST(set,b) + DEF_ASMTEST(cmov,) DEF_WLX(bsf) DEF_WLX(bsr) diff --git a/tcc.h b/tcc.h index ccbaa716..3f7d43b8 100644 --- a/tcc.h +++ b/tcc.h @@ -933,37 +933,37 @@ struct TCCState { DEF(TOK_ASM_ ## f ## x ## p, "f" #x "p") \ DEF_FP1(x) -#define DEF_ASMTEST(x) \ - DEF_ASM(x ## o) \ - DEF_ASM(x ## no) \ - DEF_ASM(x ## b) \ - DEF_ASM(x ## c) \ - DEF_ASM(x ## nae) \ - DEF_ASM(x ## nb) \ - DEF_ASM(x ## nc) \ - DEF_ASM(x ## ae) \ - DEF_ASM(x ## e) \ - DEF_ASM(x ## z) \ - DEF_ASM(x ## ne) \ - DEF_ASM(x ## nz) \ - DEF_ASM(x ## be) \ - DEF_ASM(x ## na) \ - DEF_ASM(x ## nbe) \ - DEF_ASM(x ## a) \ - DEF_ASM(x ## s) \ - DEF_ASM(x ## ns) \ - DEF_ASM(x ## p) \ - DEF_ASM(x ## pe) \ - DEF_ASM(x ## np) \ - DEF_ASM(x ## po) \ - DEF_ASM(x ## l) \ - DEF_ASM(x ## nge) \ - DEF_ASM(x ## nl) \ - DEF_ASM(x ## ge) \ - DEF_ASM(x ## le) \ - DEF_ASM(x ## ng) \ - DEF_ASM(x ## nle) \ - DEF_ASM(x ## g) +#define DEF_ASMTEST(x,suffix) \ + DEF_ASM(x ## o ## suffix) \ + DEF_ASM(x ## no ## suffix) \ + DEF_ASM(x ## b ## suffix) \ + DEF_ASM(x ## c ## suffix) \ + DEF_ASM(x ## nae ## suffix) \ + DEF_ASM(x ## nb ## suffix) \ + DEF_ASM(x ## nc ## suffix) \ + DEF_ASM(x ## ae ## suffix) \ + DEF_ASM(x ## e ## suffix) \ + DEF_ASM(x ## z ## suffix) \ + DEF_ASM(x ## ne ## suffix) \ + DEF_ASM(x ## nz ## suffix) \ + DEF_ASM(x ## be ## suffix) \ + DEF_ASM(x ## na ## suffix) \ + DEF_ASM(x ## nbe ## suffix) \ + DEF_ASM(x ## a ## suffix) \ + DEF_ASM(x ## s ## suffix) \ + DEF_ASM(x ## ns ## suffix) \ + DEF_ASM(x ## p ## suffix) \ + DEF_ASM(x ## pe ## suffix) \ + DEF_ASM(x ## np ## suffix) \ + DEF_ASM(x ## po ## suffix) \ + DEF_ASM(x ## l ## suffix) \ + DEF_ASM(x ## nge ## suffix) \ + DEF_ASM(x ## nl ## suffix) \ + DEF_ASM(x ## ge ## suffix) \ + DEF_ASM(x ## le ## suffix) \ + DEF_ASM(x ## ng ## suffix) \ + DEF_ASM(x ## nle ## suffix) \ + DEF_ASM(x ## g ## suffix) #endif /* defined TCC_TARGET_I386 || defined TCC_TARGET_X86_64 */ diff --git a/tests/asmtest.S b/tests/asmtest.S index f73878f0..e235c802 100644 --- a/tests/asmtest.S +++ b/tests/asmtest.S @@ -244,6 +244,8 @@ L3: seto %al + setc %al + setcb %al setnp 0x1000 setl 0xaaaa setg %dl diff --git a/x86_64-asm.h b/x86_64-asm.h index 31a7b382..2f80e4ba 100644 --- a/x86_64-asm.h +++ b/x86_64-asm.h @@ -204,6 +204,7 @@ ALT(DEF_ASM_OP1(ljmp, 0xff, 5, 0, OPT_EA)) ALT(DEF_ASM_OP1(int, 0xcd, 0, 0, OPT_IM8)) ALT(DEF_ASM_OP1(seto, 0x0f90, 0, OPC_MODRM | OPC_TEST, OPT_REG8 | OPT_EA)) +ALT(DEF_ASM_OP1(setob, 0x0f90, 0, OPC_MODRM | OPC_TEST, OPT_REG8 | OPT_EA)) DEF_ASM_OP2(enter, 0xc8, 0, 0, OPT_IM16, OPT_IM8) DEF_ASM_OP0(leave, 0xc9) DEF_ASM_OP0(ret, 0xc3)