From 3aac788365086260b4f8318c5563db54cd2d97fb Mon Sep 17 00:00:00 2001 From: Evan Cheng Date: Mon, 1 Sep 2008 08:25:56 +0000 Subject: [PATCH] Control flow instruction encodings. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55601 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/ARM/ARMInstrFormats.td | 78 ++++++++++++++++++++++++++----- lib/Target/ARM/ARMInstrInfo.td | 10 ++-- 2 files changed, 71 insertions(+), 17 deletions(-) diff --git a/lib/Target/ARM/ARMInstrFormats.td b/lib/Target/ARM/ARMInstrFormats.td index 16fb40505e8..d60ba5f6070 100644 --- a/lib/Target/ARM/ARMInstrFormats.td +++ b/lib/Target/ARM/ARMInstrFormats.td @@ -135,10 +135,76 @@ class AXI opcod, dag oops, dag iops, Format f, string asm, list pattern> : XI; + +// Ctrl flow instructions +class ABLpredI opcod, dag oops, dag iops, Format f, string opc, + string asm, list pattern> + : I { + let Inst{24} = 1; // L bit + let Inst{25-27} = 5; +} +class ABLI opcod, dag oops, dag iops, Format f, string asm, + list pattern> + : XI { + let Inst{24} = 1; // L bit + let Inst{25-27} = 5; +} +class ABLXI opcod, dag oops, dag iops, Format f, string asm, + list pattern> + : XI { + let Inst{4-7} = 3; + let Inst{20-27} = 0x12; +} +// FIXME: BX class AXIx2 opcod, dag oops, dag iops, Format f, string asm, list pattern> : XI; +class ABI opcod, dag oops, dag iops, Format f, string asm, + list pattern> + : XI { + let Inst{24} = 0; // L bit + let Inst{25-27} = 5; +} +class ABccI opcod, dag oops, dag iops, Format f, string opc, + string asm, list pattern> + : I { + let Inst{24} = 0; // L bit + let Inst{25-27} = 5; +} + +// BR_JT instructions +// == mov pc +class JTI opcod, dag oops, dag iops, string asm, list pattern> + : XI { + let Inst{20} = 0; // S Bit + let Inst{21-24} = 0xd; + let Inst{26-27} = 0; +} +// == ldr pc +class JTI1 opcod, dag oops, dag iops, string asm, list pattern> + : XI { + let Inst{20} = 1; // L bit + let Inst{21} = 0; // W bit + let Inst{22} = 0; // B bit + let Inst{24} = 1; // P bit +} +// == add pc +class JTI2 opcod, dag oops, dag iops, string asm, list pattern> + : XI { + let Inst{20} = 0; // S bit + let Inst{21-24} = 4; + let Inst{26-27} = 0; +} + // addrmode1 instructions class AI1 opcod, dag oops, dag iops, Format f, string opc, @@ -606,18 +672,6 @@ class AXI4st opcod, dag oops, dag iops, Format f, string asm, } -// BR_JT instructions -class JTI opcod, dag oops, dag iops, string asm, list pattern> - : XI; -class JTI1 opcod, dag oops, dag iops, string asm, list pattern> - : XI; -class JTI2 opcod, dag oops, dag iops, string asm, list pattern> - : XI; - - //===----------------------------------------------------------------------===// // ARMPat - Same as Pat<>, but requires that the compiler be in ARM mode. diff --git a/lib/Target/ARM/ARMInstrInfo.td b/lib/Target/ARM/ARMInstrInfo.td index cfc0625b625..b4a9f42f0d6 100644 --- a/lib/Target/ARM/ARMInstrInfo.td +++ b/lib/Target/ARM/ARMInstrInfo.td @@ -531,16 +531,16 @@ let isReturn = 1, isTerminator = 1 in let isCall = 1, Defs = [R0, R1, R2, R3, R12, LR, D0, D1, D2, D3, D4, D5, D6, D7, CPSR] in { - def BL : AXI<0xB, (outs), (ins i32imm:$func, variable_ops), Branch, + def BL : ABLI<0xB, (outs), (ins i32imm:$func, variable_ops), Branch, "bl ${func:call}", [(ARMcall tglobaladdr:$func)]>; - def BL_pred : AI<0xB, (outs), (ins i32imm:$func, variable_ops), - Branch, "bl", " ${func:call}", + def BL_pred : ABLpredI<0xB, (outs), (ins i32imm:$func, variable_ops), Branch, + "bl", " ${func:call}", [(ARMcall_pred tglobaladdr:$func)]>; // ARMv5T and above - def BLX : AXI<0x2, (outs), (ins GPR:$func, variable_ops), BranchMisc, + def BLX : ABLXI<0x2, (outs), (ins GPR:$func, variable_ops), BranchMisc, "blx $func", [(ARMcall GPR:$func)]>, Requires<[IsARM, HasV5T]>; let Uses = [LR] in { @@ -576,7 +576,7 @@ let isBranch = 1, isTerminator = 1 in { // FIXME: should be able to write a pattern for ARMBrcond, but can't use // a two-value operand where a dag node expects two operands. :( - def Bcc : AI<0xA, (outs), (ins brtarget:$target), Branch, + def Bcc : ABccI<0xA, (outs), (ins brtarget:$target), Branch, "b", " $target", [/*(ARMbrcond bb:$target, imm:$cc, CCR:$ccr)*/]>; } -- 2.34.1