brintos

brintos / llvm-project-archived public Read only

0
0
Text · 9.4 KiB · d0f4547 Raw
259 lines · plain
1//===- XtensaOperands.td - Xtensa instruction operands -------*- tblgen-*--===//2//3//                     The LLVM Compiler Infrastructure4//5// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.6// See https://llvm.org/LICENSE.txt for license information.7// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception8//9//===----------------------------------------------------------------------===//10 11// Immediate operands with a shared generic render method.12class ImmAsmOperand<string name> : AsmOperandClass {13  let Name = name;14  let RenderMethod = "addImmOperands";15  let DiagnosticType = !strconcat("Invalid", name);16}17 18class Immediate<ValueType vt, code pred, string asmop>19  : Operand<vt>, ImmLeaf<vt, pred> {20  let PrintMethod = "print"#asmop;21  let ParserMatchClass = !cast<AsmOperandClass>(asmop);22}23 24// imm8 predicate - Immediate in the range [-128,127]25def Imm8_AsmOperand : ImmAsmOperand<"Imm8">;26def imm8 : Immediate<i32, [{ return Imm >= -128 && Imm <= 127; }], "Imm8_AsmOperand"> {27  let EncoderMethod = "getImm8OpValue";28  let DecoderMethod = "decodeImm8Operand";29}30 31// imm8_sh8 predicate - Immediate in the range [-32768,32512] with (bits[7-0] == 0)32// imm8 value left shifted by 8 bits33def Imm8_sh8_AsmOperand : ImmAsmOperand<"Imm8_sh8">;34def imm8_sh8 : Immediate<i32, [{ return Imm >= -32768 && Imm <= 32512 && ((Imm & 0xFF) == 0); }],35                        "Imm8_sh8_AsmOperand"> {36  let EncoderMethod = "getImm8_sh8OpValue";37  let DecoderMethod = "decodeImm8_sh8Operand";38}39 40// imm8n_7 predicate - Immediate in the range [-8,7]41def Imm8n_7_AsmOperand: ImmAsmOperand<"Imm8n_7">;42def imm8n_7: Immediate<i32, [{ return Imm >= -8 && Imm <= 7; }], "Imm8n_7_AsmOperand"> {43  let EncoderMethod = "getImm8n_7OpValue";44  let DecoderMethod = "decodeImm8n_7Operand";45}46 47// imm64n_4n predicate - Immediate in the range [-64,-4]48def Imm64n_4n_AsmOperand: ImmAsmOperand<"Imm64n_4n">;49def imm64n_4n: Immediate<i32, [{ return Imm >= -64 && Imm <= -4; }], "Imm64n_4n_AsmOperand"> {50  let EncoderMethod = "getImm64n_4nOpValue";51  let DecoderMethod = "decodeImm64n_4nOperand";52}53 54// imm12 predicate - Immediate in the range [-2048,2047]55def Imm12_AsmOperand : ImmAsmOperand<"Imm12">;56def imm12 : Immediate<i32, [{ return Imm >= -2048 && Imm <= 2047; }], "Imm12_AsmOperand"> {57  let EncoderMethod = "getImm12OpValue";58  let DecoderMethod = "decodeImm12Operand";59}60 61// imm12m predicate - Immediate for MOV operation62def Imm12m_AsmOperand : ImmAsmOperand<"Imm12m">;63def imm12m : Immediate<i32, [{ return Imm >= -2048 && Imm <= 2047; }], "Imm12m_AsmOperand"> {64  let EncoderMethod = "getImm12OpValue";65  let DecoderMethod = "decodeImm12Operand";66}67 68// uimm4 predicate - Immediate in the range [0,15]69def Uimm4_AsmOperand : ImmAsmOperand<"Uimm4">;70def uimm4 : Immediate<i32, [{ return Imm >= 0 && Imm <= 15; }], "Uimm4_AsmOperand"> {71  let EncoderMethod = "getUimm4OpValue";72  let DecoderMethod = "decodeUimm4Operand";73}74 75// uimm5 predicate - Immediate in the range [0,31]76def Uimm5_AsmOperand : ImmAsmOperand<"Uimm5">;77def uimm5 : Immediate<i32, [{ return Imm >= 0 && Imm <= 31; }], "Uimm5_AsmOperand"> {78  let EncoderMethod = "getUimm5OpValue";79  let DecoderMethod = "decodeUimm5Operand";80}81 82// imm1_16 predicate - Immediate in the range [1,16]83def Imm1_16_AsmOperand : ImmAsmOperand<"Imm1_16">;84def imm1_16 : Immediate<i32, [{ return Imm >= 1 && Imm <= 16; }], "Imm1_16_AsmOperand"> {85  let EncoderMethod = "getImm1_16OpValue";86  let DecoderMethod = "decodeImm1_16Operand";87}88 89// imm1n_15 predicate - Immediate in the range [-1,15], except 090def Imm1n_15_AsmOperand: ImmAsmOperand<"Imm1n_15">;91def imm1n_15: Immediate<i32, [{ return Imm >= -1 && Imm <= 15 && Imm != 0; }], "Imm1n_15_AsmOperand"> {92  let EncoderMethod = "getImm1n_15OpValue";93  let DecoderMethod = "decodeImm1n_15Operand";94}95 96// imm32n_95 predicate - Immediate in the range [-32,95]97def Imm32n_95_AsmOperand: ImmAsmOperand<"Imm32n_95">;98def imm32n_95: Immediate<i32, [{ return Imm >= -32 && Imm <= 95; }], "Imm32n_95_AsmOperand"> {99  let EncoderMethod = "getImm32n_95OpValue";100  let DecoderMethod = "decodeImm32n_95Operand";101}102 103// shimm1_31 predicate - Immediate in the range [1,31]104def Shimm1_31_AsmOperand : ImmAsmOperand<"Shimm1_31">;105def shimm1_31 : Immediate<i32, [{ return Imm >= 1 && Imm <= 31; }], "Shimm1_31_AsmOperand"> {106  let EncoderMethod = "getShimm1_31OpValue";107  let DecoderMethod = "decodeShimm1_31Operand";108}109 110// Memory offset 0..255 for 8-bit memory accesses111def Offset8m8_AsmOperand : ImmAsmOperand<"Offset8m8">;112def offset8m8 : Immediate<i32,113    [{ return Imm >= 0 && Imm <= 255; }],114    "Offset8m8_AsmOperand">;115 116// Memory offset 0..510 for 16-bit memory accesses117def Offset8m16_AsmOperand : ImmAsmOperand<"Offset8m16">;118def offset8m16 : Immediate<i32,119    [{ return Imm >= 0 && Imm <= 510 && (Imm & 0x1 == 0); }],120    "Offset8m16_AsmOperand">;121 122// Memory offset 0..1020 for 32-bit memory accesses123def Offset8m32_AsmOperand : ImmAsmOperand<"Offset8m32">;124def offset8m32 : Immediate<i32,125    [{ return Imm >= 0 && Imm <= 1020 && (Imm & 0x3 == 0); }],126    "Offset8m32_AsmOperand">;127 128// Memory offset 0..60 for 32-bit memory accesses129def Offset4m32_AsmOperand : ImmAsmOperand<"Offset4m32">;130def offset4m32 : Immediate<i32,131    [{ return Imm >= 0 && Imm <= 60 && (Imm & 0x3 == 0); }],132    "Offset4m32_AsmOperand">;133 134// entry_imm12 predicate - Immediate in the range [0,32760], ENTRY parameter135def Entry_Imm12_AsmOperand: ImmAsmOperand<"entry_imm12">;136def entry_imm12: Immediate<i32, [{ return Imm >= 0 && Imm <= 32760 && (Imm % 8 == 0); }], "Entry_Imm12_AsmOperand"> {137  let EncoderMethod = "getEntry_Imm12OpValue";138  let DecoderMethod = "decodeEntry_Imm12OpValue";139}140 141// b4const predicate - Branch Immediate 4-bit signed operand142def B4const_AsmOperand: ImmAsmOperand<"B4const">;143def b4const: Immediate<i32,144  [{ switch (Imm) {145        case -1: case 1: case 2: case 3:  case 4:146        case 5:  case 6: case 7: case 8: case 10: case 12:147        case 16: case 32: case 64: case 128: case 256: return 1;148        default: return 0;149     }150  }],151  "B4const_AsmOperand"> {152  let EncoderMethod = "getB4constOpValue";153  let DecoderMethod = "decodeB4constOperand";154}155 156// b4constu predicate - Branch Immediate 4-bit unsigned operand157def B4constu_AsmOperand: ImmAsmOperand<"B4constu">;158def b4constu: Immediate<i32,159  [{ switch (Imm) {160        case 32768: case 65536: case 2: case 3:  case 4:161        case 5:  case 6: case 7: case 8: case 10: case 12:162        case 16: case 32: case 64: case 128: case 256: return 1;163        default: return 0;164     }165  }],166  "B4constu_AsmOperand"> {167  let EncoderMethod = "getB4constuOpValue";168  let DecoderMethod = "decodeB4constuOperand";169}170 171// imm7_22 predicate - Immediate in the range [7,22] for sign extend and clamps172def Imm7_22_AsmOperand: ImmAsmOperand<"imm7_22">;173def imm7_22: Immediate<i32, [{ return Imm >= 7 && Imm <= 22; }], "Imm7_22_AsmOperand"> {174  let EncoderMethod = "getImm7_22OpValue";175  let DecoderMethod = "decodeImm7_22Operand";176}177 178//===----------------------------------------------------------------------===//179// Memory address operands180//===----------------------------------------------------------------------===//181 182class mem<Operand offset> : Operand<i32> {183  let MIOperandInfo = (ops AR, offset);184  let EncoderMethod = "getMemRegEncoding";185  let OperandType = "OPERAND_MEMORY";186  let PrintMethod = "printMemOperand";187}188 189def mem8   : mem<offset8m8> {190  let DecoderMethod = "decodeMem8Operand";191}192 193def mem16  : mem<offset8m16> {194  let DecoderMethod = "decodeMem16Operand";195}196 197def mem32  : mem<offset8m32> {198  let DecoderMethod = "decodeMem32Operand";199}200 201def mem32n : mem<offset4m32> {202  let DecoderMethod = "decodeMem32nOperand";203}204 205//Add patterns for future use in stack addressing mode206def addr_ish1 : ComplexPattern<iPTR, 2, "selectMemRegAddrISH1", [frameindex]>;207def addr_ish2 : ComplexPattern<iPTR, 2, "selectMemRegAddrISH2", [frameindex]>;208def addr_ish4 : ComplexPattern<iPTR, 2, "selectMemRegAddrISH4", [frameindex]>;209 210//===----------------------------------------------------------------------===//211// Symbolic address operands212//===----------------------------------------------------------------------===//213def XtensaPCRelTargetAsmOperand : AsmOperandClass {214  let Name = "PCRelTarget";215  let ParserMethod = "parsePCRelTarget";216  let PredicateMethod = "isImm";217  let RenderMethod = "addImmOperands";218}219 220def  pcrel32call : Operand<iPTR> {221  let PrintMethod = "printCallOperand";222  let EncoderMethod = "getCallEncoding";223  let DecoderMethod = "decodeCallOperand";224  let ParserMatchClass = XtensaPCRelTargetAsmOperand;225  let OperandType = "OPERAND_PCREL";226}227 228def brtarget : Operand<OtherVT> {229  let PrintMethod = "printBranchTarget";230  let EncoderMethod = "getBranchTargetEncoding";231  let DecoderMethod = "decodeBranchOperand";232  let ParserMatchClass = XtensaPCRelTargetAsmOperand;233  let OperandType = "OPERAND_PCREL";234}235 236def jumptarget : Operand<OtherVT> {237  let PrintMethod = "printJumpTarget";238  let EncoderMethod = "getJumpTargetEncoding";239  let DecoderMethod = "decodeJumpOperand";240  let ParserMatchClass = XtensaPCRelTargetAsmOperand;241  let OperandType = "OPERAND_PCREL";242}243 244def ltarget : Operand<OtherVT> {245  let PrintMethod = "printLoopTarget";246  let EncoderMethod = "getLoopTargetEncoding";247  let DecoderMethod = "decodeLoopOperand";248  let ParserMatchClass = XtensaPCRelTargetAsmOperand;249  let OperandType = "OPERAND_PCREL";250}251 252def L32Rtarget : Operand<i32> {253  let PrintMethod = "printL32RTarget";254  let EncoderMethod = "getL32RTargetEncoding";255  let DecoderMethod = "decodeL32ROperand";256  let ParserMatchClass = XtensaPCRelTargetAsmOperand;257  let OperandType = "OPERAND_PCREL";258}259