-
-
Save aquynh/9cb16adcbe04a58b095d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/Target/Mips/Disassembler/MipsDisassembler.cpp b/lib/Target/Mips/Disassembler/MipsDisassembler.cpp | |
index 5d594f1..dd1a29b 100644 | |
--- a/lib/Target/Mips/Disassembler/MipsDisassembler.cpp | |
+++ b/lib/Target/Mips/Disassembler/MipsDisassembler.cpp | |
@@ -247,6 +247,11 @@ static DecodeStatus DecodeCacheOp(MCInst &Inst, | |
uint64_t Address, | |
const void *Decoder); | |
+static DecodeStatus DecodeSyncI(MCInst &Inst, | |
+ unsigned Insn, | |
+ uint64_t Address, | |
+ const void *Decoder); | |
+ | |
static DecodeStatus DecodeMSA128Mem(MCInst &Inst, unsigned Insn, | |
uint64_t Address, const void *Decoder); | |
@@ -977,6 +982,21 @@ static DecodeStatus DecodeCacheOp(MCInst &Inst, | |
return MCDisassembler::Success; | |
} | |
+static DecodeStatus DecodeSyncI(MCInst &Inst, | |
+ unsigned Insn, | |
+ uint64_t Address, | |
+ const void *Decoder) { | |
+ int Offset = SignExtend32<16>(Insn & 0xffff); | |
+ unsigned Base = fieldFromInstruction(Insn, 21, 5); | |
+ | |
+ Base = getReg(Decoder, Mips::GPR32RegClassID, Base); | |
+ | |
+ Inst.addOperand(MCOperand::CreateReg(Base)); | |
+ Inst.addOperand(MCOperand::CreateImm(Offset)); | |
+ | |
+ return MCDisassembler::Success; | |
+} | |
+ | |
static DecodeStatus DecodeMSA128Mem(MCInst &Inst, unsigned Insn, | |
uint64_t Address, const void *Decoder) { | |
int Offset = SignExtend32<10>(fieldFromInstruction(Insn, 16, 10)); | |
diff --git a/lib/Target/Mips/MipsInstrFormats.td b/lib/Target/Mips/MipsInstrFormats.td | |
index 6a01ae5..23f7844 100644 | |
--- a/lib/Target/Mips/MipsInstrFormats.td | |
+++ b/lib/Target/Mips/MipsInstrFormats.td | |
@@ -411,6 +411,18 @@ class SYNC_FM : StdArch { | |
let Inst{5-0} = 0xf; | |
} | |
+class SYNCI_FM : StdArch { | |
+ bits<5> rs; | |
+ bits<16> imm; | |
+ | |
+ bits<32> Inst; | |
+ | |
+ let Inst{31-26} = 0b000001; | |
+ let Inst{25-21} = rs; | |
+ let Inst{20-16} = 0b11111; | |
+ let Inst{15-0} = imm; | |
+} | |
+ | |
class MULT_FM<bits<6> op, bits<6> funct> : StdArch { | |
bits<5> rs; | |
bits<5> rt; | |
diff --git a/lib/Target/Mips/MipsInstrInfo.td b/lib/Target/Mips/MipsInstrInfo.td | |
index 93ea6f6..e2bf987 100644 | |
--- a/lib/Target/Mips/MipsInstrInfo.td | |
+++ b/lib/Target/Mips/MipsInstrInfo.td | |
@@ -428,6 +428,15 @@ def MipsMemSimm11AsmOperand : AsmOperandClass { | |
//let DiagnosticType = "Simm11"; | |
} | |
+def MipsMemSimm16AsmOperand : AsmOperandClass { | |
+ let Name = "MemOffsetSimm16"; | |
+ let SuperClasses = [MipsMemAsmOperand]; | |
+ let RenderMethod = "addMemOperands"; | |
+ let ParserMethod = "parseMemOperand"; | |
+ let PredicateMethod = "isMemWithSimmOffset<16>"; | |
+ //let DiagnosticType = "Simm16"; | |
+} | |
+ | |
def MipsInvertedImmoperand : AsmOperandClass { | |
let Name = "InvNum"; | |
let RenderMethod = "addImmOperands"; | |
@@ -470,6 +479,12 @@ def mem_simm11 : mem_generic { | |
let ParserMatchClass = MipsMemSimm11AsmOperand; | |
} | |
+def mem_simm16 : mem_generic { | |
+ let MIOperandInfo = (ops ptr_rc, simm16); | |
+ let EncoderMethod = "getMemEncoding"; | |
+ let ParserMatchClass = MipsMemSimm16AsmOperand; | |
+} | |
+ | |
def mem_ea : Operand<iPTR> { | |
let PrintMethod = "printMemOperandEA"; | |
let MIOperandInfo = (ops ptr_rc, simm16); | |
@@ -860,6 +875,13 @@ class SYNC_FT<string opstr> : | |
InstSE<(outs), (ins i32imm:$stype), "sync $stype", [(MipsSync imm:$stype)], | |
NoItinerary, FrmOther, opstr>; | |
+class SYNCI_FT<string opstr> : | |
+ InstSE<(outs), (ins mem_simm16:$addr), !strconcat(opstr, "\t$addr"), [], | |
+ NoItinerary, FrmOther, opstr> { | |
+ let hasSideEffects = 1; | |
+ let DecoderMethod = "DecodeSyncI"; | |
+} | |
+ | |
let hasSideEffects = 1 in | |
class TEQ_FT<string opstr, RegisterOperand RO> : | |
InstSE<(outs), (ins RO:$rs, RO:$rt, uimm16:$code_), | |
@@ -1208,6 +1230,7 @@ let DecoderNamespace = "COP3_" in { | |
} | |
def SYNC : MMRel, SYNC_FT<"sync">, SYNC_FM, ISA_MIPS32; | |
+def SYNCI : MMRel, SYNCI_FT<"synci">, SYNCI_FM, ISA_MIPS32R2; | |
def TEQ : MMRel, TEQ_FT<"teq", GPR32Opnd>, TEQ_FM<0x34>, ISA_MIPS2; | |
def TGE : MMRel, TEQ_FT<"tge", GPR32Opnd>, TEQ_FM<0x30>, ISA_MIPS2; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment