[llvm] 7deb8ce - [mips] Joint MipsMemSimmXXXAsmOperand into the single template class. NFC
Simon Atanasyan via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 19 02:59:07 PST 2019
Author: Simon Atanasyan
Date: 2019-11-19T13:58:28+03:00
New Revision: 7deb8ce4c161e9715181bd3618f059e8a4a742bb
URL: https://github.com/llvm/llvm-project/commit/7deb8ce4c161e9715181bd3618f059e8a4a742bb
DIFF: https://github.com/llvm/llvm-project/commit/7deb8ce4c161e9715181bd3618f059e8a4a742bb.diff
LOG: [mips] Joint MipsMemSimmXXXAsmOperand into the single template class. NFC
Added:
Modified:
llvm/lib/Target/Mips/MicroMipsInstrInfo.td
llvm/lib/Target/Mips/MipsInstrInfo.td
Removed:
################################################################################
diff --git a/llvm/lib/Target/Mips/MicroMipsInstrInfo.td b/llvm/lib/Target/Mips/MicroMipsInstrInfo.td
index f1db250808a1..b707f1b96184 100644
--- a/llvm/lib/Target/Mips/MicroMipsInstrInfo.td
+++ b/llvm/lib/Target/Mips/MicroMipsInstrInfo.td
@@ -116,7 +116,7 @@ def mem_mm_9 : Operand<i32> {
let PrintMethod = "printMemOperand";
let MIOperandInfo = (ops ptr_rc, simm9);
let EncoderMethod = "getMemEncodingMMImm9";
- let ParserMatchClass = MipsMemSimm9AsmOperand;
+ let ParserMatchClass = MipsMemSimmAsmOperand<9>;
let OperandType = "OPERAND_MEMORY";
}
@@ -124,7 +124,7 @@ def mem_mm_11 : Operand<i32> {
let PrintMethod = "printMemOperand";
let MIOperandInfo = (ops GPR32, simm11);
let EncoderMethod = "getMemEncodingMMImm11";
- let ParserMatchClass = MipsMemSimm11AsmOperand;
+ let ParserMatchClass = MipsMemSimmAsmOperand<11>;
let OperandType = "OPERAND_MEMORY";
}
@@ -141,7 +141,7 @@ def mem_mm_16 : Operand<i32> {
let MIOperandInfo = (ops ptr_rc, simm16);
let EncoderMethod = "getMemEncodingMMImm16";
let DecoderMethod = "DecodeMemMMImm16";
- let ParserMatchClass = MipsMemSimm16AsmOperand;
+ let ParserMatchClass = MipsMemSimmAsmOperand<16>;
let OperandType = "OPERAND_MEMORY";
}
diff --git a/llvm/lib/Target/Mips/MipsInstrInfo.td b/llvm/lib/Target/Mips/MipsInstrInfo.td
index 9b2d87d67250..4c277113d54f 100644
--- a/llvm/lib/Target/Mips/MipsInstrInfo.td
+++ b/llvm/lib/Target/Mips/MipsInstrInfo.td
@@ -1086,59 +1086,14 @@ def MipsMemAsmOperand : AsmOperandClass {
let ParserMethod = "parseMemOperand";
}
-def MipsMemSimm9AsmOperand : AsmOperandClass {
- let Name = "MemOffsetSimm9";
+class MipsMemSimmAsmOperand<int Width, int Shift = 0> : AsmOperandClass {
+ let Name = "MemOffsetSimm" # Width # "_" # Shift;
let SuperClasses = [MipsMemAsmOperand];
let RenderMethod = "addMemOperands";
let ParserMethod = "parseMemOperand";
- let PredicateMethod = "isMemWithSimmOffset<9>";
- let DiagnosticType = "MemSImm9";
-}
-
-def MipsMemSimm10AsmOperand : AsmOperandClass {
- let Name = "MemOffsetSimm10";
- let SuperClasses = [MipsMemAsmOperand];
- let RenderMethod = "addMemOperands";
- let ParserMethod = "parseMemOperand";
- let PredicateMethod = "isMemWithSimmOffset<10>";
- let DiagnosticType = "MemSImm10";
-}
-
-def MipsMemSimm12AsmOperand : AsmOperandClass {
- let Name = "MemOffsetSimm12";
- let SuperClasses = [MipsMemAsmOperand];
- let RenderMethod = "addMemOperands";
- let ParserMethod = "parseMemOperand";
- let PredicateMethod = "isMemWithSimmOffset<12>";
- let DiagnosticType = "MemSImm12";
-}
-
-foreach I = {1, 2, 3} in
- def MipsMemSimm10Lsl # I # AsmOperand : AsmOperandClass {
- let Name = "MemOffsetSimm10_" # I;
- let SuperClasses = [MipsMemAsmOperand];
- let RenderMethod = "addMemOperands";
- let ParserMethod = "parseMemOperand";
- let PredicateMethod = "isMemWithSimmOffset<10, " # I # ">";
- let DiagnosticType = "MemSImm10Lsl" # I;
- }
-
-def MipsMemSimm11AsmOperand : AsmOperandClass {
- let Name = "MemOffsetSimm11";
- let SuperClasses = [MipsMemAsmOperand];
- let RenderMethod = "addMemOperands";
- let ParserMethod = "parseMemOperand";
- let PredicateMethod = "isMemWithSimmOffset<11>";
- let DiagnosticType = "MemSImm11";
-}
-
-def MipsMemSimm16AsmOperand : AsmOperandClass {
- let Name = "MemOffsetSimm16";
- let SuperClasses = [MipsMemAsmOperand];
- let RenderMethod = "addMemOperands";
- let ParserMethod = "parseMemOperand";
- let PredicateMethod = "isMemWithSimmOffset<16>";
- let DiagnosticType = "MemSImm16";
+ let PredicateMethod = "isMemWithSimmOffset<" # Width # ", " # Shift # ">";
+ let DiagnosticType = !if(!eq(Shift, 0), "MemSImm" # Width,
+ "MemSImm" # Width # "Lsl" # Shift);
}
def MipsMemSimmPtrAsmOperand : AsmOperandClass {
@@ -1188,39 +1143,38 @@ def simm12 : Operand<i32> {
def mem_simm9 : mem_generic {
let MIOperandInfo = (ops ptr_rc, simm9);
let EncoderMethod = "getMemEncoding";
- let ParserMatchClass = MipsMemSimm9AsmOperand;
+ let ParserMatchClass = MipsMemSimmAsmOperand<9>;
}
def mem_simm10 : mem_generic {
let MIOperandInfo = (ops ptr_rc, simm10);
let EncoderMethod = "getMemEncoding";
- let ParserMatchClass = MipsMemSimm10AsmOperand;
+ let ParserMatchClass = MipsMemSimmAsmOperand<10>;
}
foreach I = {1, 2, 3} in
def mem_simm10_lsl # I : mem_generic {
let MIOperandInfo = (ops ptr_rc, !cast<Operand>("simm10_lsl" # I));
let EncoderMethod = "getMemEncoding<" # I # ">";
- let ParserMatchClass =
- !cast<AsmOperandClass>("MipsMemSimm10Lsl" # I # "AsmOperand");
+ let ParserMatchClass = MipsMemSimmAsmOperand<10, I>;
}
def mem_simm11 : mem_generic {
let MIOperandInfo = (ops ptr_rc, simm11);
let EncoderMethod = "getMemEncoding";
- let ParserMatchClass = MipsMemSimm11AsmOperand;
+ let ParserMatchClass = MipsMemSimmAsmOperand<11>;
}
def mem_simm12 : mem_generic {
let MIOperandInfo = (ops ptr_rc, simm12);
let EncoderMethod = "getMemEncoding";
- let ParserMatchClass = MipsMemSimm12AsmOperand;
+ let ParserMatchClass = MipsMemSimmAsmOperand<12>;
}
def mem_simm16 : mem_generic {
let MIOperandInfo = (ops ptr_rc, simm16);
let EncoderMethod = "getMemEncoding";
- let ParserMatchClass = MipsMemSimm16AsmOperand;
+ let ParserMatchClass = MipsMemSimmAsmOperand<16>;
}
def mem_simmptr : mem_generic {
More information about the llvm-commits
mailing list