From fd2d7dcc312916bff767158b1efef3460dbcf759 Mon Sep 17 00:00:00 2001 From: Akira Hatanaka Date: Tue, 11 Oct 2011 00:11:12 +0000 Subject: [PATCH] Change definitions of classes LoadM and StoreM in preparation for adding support for 64-bit load and store instructions. Add definitions of 64-bit memory operand and 16-bit immediate operand. llvm-svn: 141603 --- llvm/lib/Target/Mips/Mips64InstrInfo.td | 1 - llvm/lib/Target/Mips/MipsInstrInfo.td | 84 +++++++++++++++++++------ 2 files changed, 65 insertions(+), 20 deletions(-) diff --git a/llvm/lib/Target/Mips/Mips64InstrInfo.td b/llvm/lib/Target/Mips/Mips64InstrInfo.td index cd185f6a3c50..012ee1edf634 100644 --- a/llvm/lib/Target/Mips/Mips64InstrInfo.td +++ b/llvm/lib/Target/Mips/Mips64InstrInfo.td @@ -22,7 +22,6 @@ def HasMips64r2 : Predicate<"Subtarget.hasMips64r2()">; //===----------------------------------------------------------------------===// // Instruction operand types -def simm16_64 : Operand; def shamt_64 : Operand; // Unsigned Operand diff --git a/llvm/lib/Target/Mips/MipsInstrInfo.td b/llvm/lib/Target/Mips/MipsInstrInfo.td index e446e6a143d8..a40442fe023d 100644 --- a/llvm/lib/Target/Mips/MipsInstrInfo.td +++ b/llvm/lib/Target/Mips/MipsInstrInfo.td @@ -127,6 +127,8 @@ def HasSwap : Predicate<"Subtarget.hasSwap()">; def HasCondMov : Predicate<"Subtarget.hasCondMov()">; def HasMips32 : Predicate<"Subtarget.hasMips32()">; def HasMips32r2 : Predicate<"Subtarget.hasMips32r2()">; +def IsN64 : Predicate<"Subtarget.isABI_N64()">; +def NotN64 : Predicate<"!Subtarget.isABI_N64()">; //===----------------------------------------------------------------------===// // Mips Operand, Complex Patterns and Transformations Definitions. @@ -136,6 +138,7 @@ def HasMips32r2 : Predicate<"Subtarget.hasMips32r2()">; def brtarget : Operand; def calltarget : Operand; def simm16 : Operand; +def simm16_64 : Operand; def shamt : Operand; // Unsigned Operand @@ -149,6 +152,11 @@ def mem : Operand { let MIOperandInfo = (ops CPURegs, simm16); } +def mem64 : Operand { + let PrintMethod = "printMemOperand"; + let MIOperandInfo = (ops CPU64Regs, simm16_64); +} + def mem_ea : Operand { let PrintMethod = "printMemOperandEA"; let MIOperandInfo = (ops CPURegs, simm16); @@ -313,20 +321,58 @@ class LoadUpper op, string instr_asm>: // Memory Load/Store let canFoldAsLoad = 1 in -class LoadM op, string instr_asm, PatFrag OpNode, bit Pseudo = 0>: - FI op, string instr_asm, PatFrag OpNode, RegisterClass RC, + Operand MemOpnd, bit Pseudo>: + FI { + [(set RC:$dst, (OpNode addr:$addr))], IILoad> { let isPseudo = Pseudo; } -class StoreM op, string instr_asm, PatFrag OpNode, bit Pseudo = 0>: - FI op, string instr_asm, PatFrag OpNode, RegisterClass RC, + Operand MemOpnd, bit Pseudo>: + FI { + [(OpNode RC:$dst, addr:$addr)], IIStore> { let isPseudo = Pseudo; } +// 32-bit load. +multiclass LoadM32 op, string instr_asm, PatFrag OpNode, + bit Pseudo = 0> { + def #NAME# : LoadM, + Requires<[NotN64]>; + def _P8 : LoadM, + Requires<[IsN64]>; +} + +// 64-bit load. +multiclass LoadM64 op, string instr_asm, PatFrag OpNode, + bit Pseudo = 0> { + def #NAME# : LoadM, + Requires<[NotN64]>; + def _P8 : LoadM, + Requires<[IsN64]>; +} + +// 32-bit store. +multiclass StoreM32 op, string instr_asm, PatFrag OpNode, + bit Pseudo = 0> { + def #NAME# : StoreM, + Requires<[NotN64]>; + def _P8 : StoreM, + Requires<[IsN64]>; +} + +// 64-bit store. +multiclass StoreM64 op, string instr_asm, PatFrag OpNode, + bit Pseudo = 0> { + def #NAME# : StoreM, + Requires<[NotN64]>; + def _P8 : StoreM, + Requires<[IsN64]>; +} + // Conditional Branch let isBranch = 1, isTerminator=1, hasDelaySlot = 1 in { class CBranch op, string instr_asm, PatFrag cond_op>: @@ -587,21 +633,21 @@ let Predicates = [HasMips32r2] in { /// Load and Store Instructions /// aligned -def LB : LoadM<0x20, "lb", sextloadi8>; -def LBu : LoadM<0x24, "lbu", zextloadi8>; -def LH : LoadM<0x21, "lh", sextloadi16_a>; -def LHu : LoadM<0x25, "lhu", zextloadi16_a>; -def LW : LoadM<0x23, "lw", load_a>; -def SB : StoreM<0x28, "sb", truncstorei8>; -def SH : StoreM<0x29, "sh", truncstorei16_a>; -def SW : StoreM<0x2b, "sw", store_a>; +defm LB : LoadM32<0x20, "lb", sextloadi8>; +defm LBu : LoadM32<0x24, "lbu", zextloadi8>; +defm LH : LoadM32<0x21, "lh", sextloadi16_a>; +defm LHu : LoadM32<0x25, "lhu", zextloadi16_a>; +defm LW : LoadM32<0x23, "lw", load_a>; +defm SB : StoreM32<0x28, "sb", truncstorei8>; +defm SH : StoreM32<0x29, "sh", truncstorei16_a>; +defm SW : StoreM32<0x2b, "sw", store_a>; /// unaligned -def ULH : LoadM<0x21, "ulh", sextloadi16_u, 1>; -def ULHu : LoadM<0x25, "ulhu", zextloadi16_u, 1>; -def ULW : LoadM<0x23, "ulw", load_u, 1>; -def USH : StoreM<0x29, "ush", truncstorei16_u, 1>; -def USW : StoreM<0x2b, "usw", store_u, 1>; +defm ULH : LoadM32<0x21, "ulh", sextloadi16_u, 1>; +defm ULHu : LoadM32<0x25, "ulhu", zextloadi16_u, 1>; +defm ULW : LoadM32<0x23, "ulw", load_u, 1>; +defm USH : StoreM32<0x29, "ush", truncstorei16_u, 1>; +defm USW : StoreM32<0x2b, "usw", store_u, 1>; let hasSideEffects = 1 in def SYNC : MipsInst<(outs), (ins i32imm:$stype), "sync $stype",