1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 19:23:23 +01:00

Fix ssat and ssat16 encodings for ARM and Thumb. The bit position value

must be encoded decremented by one. Only add encoding tests for ssat16
because ssat can't be parsed yet.

llvm-svn: 132324
This commit is contained in:
Bruno Cardoso Lopes 2011-05-31 03:33:27 +00:00
parent 728ea362c3
commit 0bdb365634
7 changed files with 32 additions and 8 deletions

View File

@ -232,6 +232,8 @@ namespace {
unsigned Op) const { return 0; } unsigned Op) const { return 0; }
unsigned getMsbOpValue(const MachineInstr &MI, unsigned getMsbOpValue(const MachineInstr &MI,
unsigned Op) const { return 0; } unsigned Op) const { return 0; }
unsigned getSsatBitPosValue(const MachineInstr &MI,
unsigned Op) const { return 0; }
uint32_t getLdStmModeOpValue(const MachineInstr &MI, unsigned OpIdx) uint32_t getLdStmModeOpValue(const MachineInstr &MI, unsigned OpIdx)
const {return 0; } const {return 0; }
uint32_t getLdStSORegOpValue(const MachineInstr &MI, unsigned OpIdx) uint32_t getLdStSORegOpValue(const MachineInstr &MI, unsigned OpIdx)

View File

@ -475,6 +475,12 @@ def width_imm : Operand<i32>, ImmLeaf<i32, [{
let EncoderMethod = "getMsbOpValue"; let EncoderMethod = "getMsbOpValue";
} }
def ssat_imm : Operand<i32>, ImmLeaf<i32, [{
return Imm > 0 && Imm <= 32;
}]> {
let EncoderMethod = "getSsatBitPosValue";
}
// Define ARM specific addressing modes. // Define ARM specific addressing modes.
def MemMode2AsmOperand : AsmOperandClass { def MemMode2AsmOperand : AsmOperandClass {
@ -2455,7 +2461,7 @@ def USADA8 : AI<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
// Signed/Unsigned saturate -- for disassembly only // Signed/Unsigned saturate -- for disassembly only
def SSAT : AI<(outs GPR:$Rd), (ins i32imm:$sat_imm, GPR:$a, shift_imm:$sh), def SSAT : AI<(outs GPR:$Rd), (ins ssat_imm:$sat_imm, GPR:$a, shift_imm:$sh),
SatFrm, NoItinerary, "ssat", "\t$Rd, $sat_imm, $a$sh", SatFrm, NoItinerary, "ssat", "\t$Rd, $sat_imm, $a$sh",
[/* For disassembly only; pattern left blank */]> { [/* For disassembly only; pattern left blank */]> {
bits<4> Rd; bits<4> Rd;
@ -2471,7 +2477,7 @@ def SSAT : AI<(outs GPR:$Rd), (ins i32imm:$sat_imm, GPR:$a, shift_imm:$sh),
let Inst{3-0} = Rn; let Inst{3-0} = Rn;
} }
def SSAT16 : AI<(outs GPR:$Rd), (ins i32imm:$sat_imm, GPR:$Rn), SatFrm, def SSAT16 : AI<(outs GPR:$Rd), (ins ssat_imm:$sat_imm, GPR:$Rn), SatFrm,
NoItinerary, "ssat16", "\t$Rd, $sat_imm, $Rn", NoItinerary, "ssat16", "\t$Rd, $sat_imm, $Rn",
[/* For disassembly only; pattern left blank */]> { [/* For disassembly only; pattern left blank */]> {
bits<4> Rd; bits<4> Rd;

View File

@ -1973,9 +1973,9 @@ class T2SatI<dag oops, dag iops, InstrItinClass itin,
} }
def t2SSAT: T2SatI< def t2SSAT: T2SatI<
(outs rGPR:$Rd), (ins i32imm:$sat_imm, rGPR:$Rn, shift_imm:$sh), (outs rGPR:$Rd), (ins ssat_imm:$sat_imm, rGPR:$Rn, shift_imm:$sh),
NoItinerary, "ssat", "\t$Rd, $sat_imm, $Rn$sh", NoItinerary, "ssat", "\t$Rd, $sat_imm, $Rn$sh",
[/* For disassembly only; pattern left blank */]> { [/* For disassembly only; pattern left blank */]> {
let Inst{31-27} = 0b11110; let Inst{31-27} = 0b11110;
let Inst{25-22} = 0b1100; let Inst{25-22} = 0b1100;
let Inst{20} = 0; let Inst{20} = 0;
@ -1983,9 +1983,9 @@ def t2SSAT: T2SatI<
} }
def t2SSAT16: T2SatI< def t2SSAT16: T2SatI<
(outs rGPR:$Rd), (ins i32imm:$sat_imm, rGPR:$Rn), NoItinerary, (outs rGPR:$Rd), (ins ssat_imm:$sat_imm, rGPR:$Rn), NoItinerary,
"ssat16", "\t$Rd, $sat_imm, $Rn", "ssat16", "\t$Rd, $sat_imm, $Rn",
[/* For disassembly only; pattern left blank */]> { [/* For disassembly only; pattern left blank */]> {
let Inst{31-27} = 0b11110; let Inst{31-27} = 0b11110;
let Inst{25-22} = 0b1100; let Inst{25-22} = 0b1100;
let Inst{20} = 0; let Inst{20} = 0;

View File

@ -269,6 +269,9 @@ public:
unsigned getMsbOpValue(const MCInst &MI, unsigned Op, unsigned getMsbOpValue(const MCInst &MI, unsigned Op,
SmallVectorImpl<MCFixup> &Fixups) const; SmallVectorImpl<MCFixup> &Fixups) const;
unsigned getSsatBitPosValue(const MCInst &MI, unsigned Op,
SmallVectorImpl<MCFixup> &Fixups) const;
unsigned getRegisterListOpValue(const MCInst &MI, unsigned Op, unsigned getRegisterListOpValue(const MCInst &MI, unsigned Op,
SmallVectorImpl<MCFixup> &Fixups) const; SmallVectorImpl<MCFixup> &Fixups) const;
unsigned getAddrMode6AddressOpValue(const MCInst &MI, unsigned Op, unsigned getAddrMode6AddressOpValue(const MCInst &MI, unsigned Op,
@ -1123,6 +1126,13 @@ getMsbOpValue(const MCInst &MI, unsigned Op,
return msb; return msb;
} }
unsigned ARMMCCodeEmitter::
getSsatBitPosValue(const MCInst &MI, unsigned Op,
SmallVectorImpl<MCFixup> &Fixups) const {
// For ssat instructions, the bit position should be encoded decremented by 1
return MI.getOperand(Op).getImm()-1;
}
unsigned ARMMCCodeEmitter:: unsigned ARMMCCodeEmitter::
getRegisterListOpValue(const MCInst &MI, unsigned Op, getRegisterListOpValue(const MCInst &MI, unsigned Op,
SmallVectorImpl<MCFixup> &Fixups) const { SmallVectorImpl<MCFixup> &Fixups) const {

View File

@ -312,3 +312,6 @@
@ CHECK: ldrexd r0, r1, [r0] @ encoding: [0x9f,0x0f,0xb0,0xe1] @ CHECK: ldrexd r0, r1, [r0] @ encoding: [0x9f,0x0f,0xb0,0xe1]
ldrexd r0, r1, [r0] ldrexd r0, r1, [r0]
@ CHECK: ssat16 r0, #7, r0 @ encoding: [0x30,0x0f,0xa6,0xe6]
ssat16 r0, #7, r0

View File

@ -300,3 +300,5 @@
ldrex r0, [r0] ldrex r0, [r0]
@ CHECK: ldrexd r0, r1, [r0] @ encoding: [0xd0,0xe8,0x7f,0x01] @ CHECK: ldrexd r0, r1, [r0] @ encoding: [0xd0,0xe8,0x7f,0x01]
ldrexd r0, r1, [r0] ldrexd r0, r1, [r0]
@ CHECK: ssat16 r0, #7, r0 @ encoding: [0x20,0xf3,0x06,0x00]
ssat16 r0, #7, r0

View File

@ -596,6 +596,7 @@ static int ARMFlagFromOpName(LiteralConstantEmitter *type,
IMM("t_adrlabel"); IMM("t_adrlabel");
IMM("t2adrlabel"); IMM("t2adrlabel");
IMM("shift_imm"); IMM("shift_imm");
IMM("ssat_imm");
IMM("neon_vcvt_imm32"); IMM("neon_vcvt_imm32");
IMM("shr_imm8"); IMM("shr_imm8");
IMM("shr_imm16"); IMM("shr_imm16");