From 3af4a0b4cb5439d09332a04ee98a3be86a3e3e1e Mon Sep 17 00:00:00 2001 From: Anton Korobeynikov Date: Fri, 15 Jan 2010 21:17:13 +0000 Subject: [PATCH] Add instruction formats & support stuff git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93550 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/MSP430/MSP430InstrFormats.td | 125 ++++++++++++++++++++++-- 1 file changed, 115 insertions(+), 10 deletions(-) diff --git a/lib/Target/MSP430/MSP430InstrFormats.td b/lib/Target/MSP430/MSP430InstrFormats.td index 61b33990164..18ee61c6d61 100644 --- a/lib/Target/MSP430/MSP430InstrFormats.td +++ b/lib/Target/MSP430/MSP430InstrFormats.td @@ -11,8 +11,37 @@ // Describe MSP430 instructions format here // +// Format specifies the encoding used by the instruction. This is part of the +// ad-hoc solution used to emit machine instruction encodings by our machine +// code emitter. +class Format val> { + bits<2> Value = val; +} + +class SourceMode val> { + bits<2> Value = val; +} + +class DestMode { + bit Value = val; +} + +def PseudoFrm : Format<0>; +def SingleOpFrm : Format<1>; +def DoubleOpFrm : Format<2>; +def CondJumpFrm : Format<3>; + +def DstReg : DestMode<0>; +def DstMem : DestMode<1>; + +def SrcReg : SourceMode<0>; +def SrcMem : SourceMode<1>; +def SrcIndReg : SourceMode<2>; +def SrcPostInc : SourceMode<3>; +def SrcImm : SourceMode<3>; + // Generic MSP430 Format -class MSP430Inst : Instruction { +class MSP430Inst : Instruction { field bits<16> Inst; let Namespace = "MSP430"; @@ -20,38 +49,114 @@ class MSP430Inst : Instruction { dag OutOperandList = outs; dag InOperandList = ins; + Format Form = f; + bits<2> FormBits = Form.Value; + let AsmString = asmstr; } // FIXME: Create different classes for different addressing modes. // MSP430 Double Operand (Format I) Instructions -class IForm opcode, bit ad, bit bw, bits<2> as, +class IForm opcode, DestMode dest, bit bw, SourceMode src, dag outs, dag ins, string asmstr, list pattern> - : MSP430Inst { + : MSP430Inst { let Pattern = pattern; + + DestMode ad = dest; + SourceMode as = src; let Inst{12-15} = opcode; - let Inst{7} = ad; + let Inst{7} = ad.Value; let Inst{6} = bw; - let Inst{4-5} = as; + let Inst{4-5} = as.Value; } +// 8 bit IForm instructions +class IForm8 opcode, DestMode dest, SourceMode src, + dag outs, dag ins, string asmstr, list pattern> + : IForm; + +class I8rr opcode, + dag outs, dag ins, string asmstr, list pattern> + : IForm8; + +class I8ri opcode, + dag outs, dag ins, string asmstr, list pattern> + : IForm8; + +class I8rm opcode, + dag outs, dag ins, string asmstr, list pattern> + : IForm8; + +class I8mr opcode, + dag outs, dag ins, string asmstr, list pattern> + : IForm8; + +class I8mi opcode, + dag outs, dag ins, string asmstr, list pattern> + : IForm8; + +class I8mm opcode, + dag outs, dag ins, string asmstr, list pattern> + : IForm8; + +// 16 bit IForm instructions +class IForm16 opcode, DestMode dest, SourceMode src, + dag outs, dag ins, string asmstr, list pattern> + : IForm; + +class I16rr opcode, + dag outs, dag ins, string asmstr, list pattern> + : IForm16; + +class I16ri opcode, + dag outs, dag ins, string asmstr, list pattern> + : IForm16; + +class I16rm opcode, + dag outs, dag ins, string asmstr, list pattern> + : IForm16; + +class I16mr opcode, + dag outs, dag ins, string asmstr, list pattern> + : IForm16; + +class I16mi opcode, + dag outs, dag ins, string asmstr, list pattern> + : IForm16; + +class I16mm opcode, + dag outs, dag ins, string asmstr, list pattern> + : IForm16; + // MSP430 Single Operand (Format II) Instructions -class IIForm opcode, bit bw, bits<2> ad, +class IIForm opcode, bit bw, SourceMode src, dag outs, dag ins, string asmstr, list pattern> - : MSP430Inst { + : MSP430Inst { let Pattern = pattern; + SourceMode as = src; + let Inst{7-15} = opcode; let Inst{6} = bw; - let Inst{4-5} = ad; + let Inst{4-5} = as.Value; } +// 8 bit IIForm instructions +class IIForm8 opcode, SourceMode src, + dag outs, dag ins, string asmstr, list pattern> + : IIForm; + +// 16 bit IIForm instructions +class IIForm16 opcode, SourceMode src, + dag outs, dag ins, string asmstr, list pattern> + : IIForm; + // MSP430 Conditional Jumps Instructions class CJForm opcode, bits<3> cond, bit s, dag outs, dag ins, string asmstr, list pattern> - : MSP430Inst { + : MSP430Inst { let Pattern = pattern; let Inst{13-15} = opcode; @@ -61,7 +166,7 @@ class CJForm opcode, bits<3> cond, bit s, // Pseudo instructions class Pseudo pattern> - : MSP430Inst { + : MSP430Inst { let Pattern = pattern; let Inst{15-0} = 0; } -- 2.34.1