Skip to content

Commit 70b5b14

Browse files
committed
[MIPS] Fix the func opcode for mina.fmt and max.fmt
- The opcode of the mina.fmt and max.fmt is documented wrong, the object code compiled from the same assembly with LLVM behaves differently than one compiled with GCC and Binutils. - Modify the opcodes to match Binutils. The actual opcodes are as follows: {5,3}| bits {2,0} of func | ... | 100 | 101 | 110 | 111 -----+-----+-----+-----+-----+----- 010 | ... | min | mina| max | maxa
1 parent 56e3249 commit 70b5b14

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

llvm/lib/Target/Mips/Mips32r6InstrInfo.td

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,15 +153,15 @@ class SELNEZ_ENC : SPECIAL_3R_FM<0b00000, 0b110111>;
153153

154154
class LWPC_ENC : PCREL19_FM<OPCODE2_LWPC>;
155155

156-
class MAX_S_ENC : COP1_3R_FM<0b011101, FIELD_FMT_S>;
157-
class MAX_D_ENC : COP1_3R_FM<0b011101, FIELD_FMT_D>;
156+
class MAX_S_ENC : COP1_3R_FM<0b011110, FIELD_FMT_S>;
157+
class MAX_D_ENC : COP1_3R_FM<0b011110, FIELD_FMT_D>;
158158
class MIN_S_ENC : COP1_3R_FM<0b011100, FIELD_FMT_S>;
159159
class MIN_D_ENC : COP1_3R_FM<0b011100, FIELD_FMT_D>;
160160

161161
class MAXA_S_ENC : COP1_3R_FM<0b011111, FIELD_FMT_S>;
162162
class MAXA_D_ENC : COP1_3R_FM<0b011111, FIELD_FMT_D>;
163-
class MINA_S_ENC : COP1_3R_FM<0b011110, FIELD_FMT_S>;
164-
class MINA_D_ENC : COP1_3R_FM<0b011110, FIELD_FMT_D>;
163+
class MINA_S_ENC : COP1_3R_FM<0b011101, FIELD_FMT_S>;
164+
class MINA_D_ENC : COP1_3R_FM<0b011101, FIELD_FMT_D>;
165165

166166
class SELEQZ_S_ENC : COP1_3R_FM<0b010100, FIELD_FMT_S>;
167167
class SELEQZ_D_ENC : COP1_3R_FM<0b010100, FIELD_FMT_D>;
@@ -1117,6 +1117,22 @@ def : MipsPat<(select i32:$cond, immz, i32:$f),
11171117
ISA_MIPS32R6;
11181118
}
11191119

1120+
// llvm.fmin/fmax operations.
1121+
let AdditionalPredicates = [NotInMicroMips] in {
1122+
def : MipsPat<(fmaxnum f32:$lhs, f32:$rhs),
1123+
(MAX_S f32:$lhs, f32:$rhs)>,
1124+
ISA_MIPS32R6;
1125+
def : MipsPat<(fmaxnum f64:$lhs, f64:$rhs),
1126+
(MAX_D f64:$lhs, f64:$rhs)>,
1127+
ISA_MIPS32R6;
1128+
def : MipsPat<(fminnum f32:$lhs, f32:$rhs),
1129+
(MIN_S f32:$lhs, f32:$rhs)>,
1130+
ISA_MIPS32R6;
1131+
def : MipsPat<(fminnum f64:$lhs, f64:$rhs),
1132+
(MIN_D f64:$lhs, f64:$rhs)>,
1133+
ISA_MIPS32R6;
1134+
}
1135+
11201136
// Pseudo instructions
11211137
let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, hasDelaySlot = 1,
11221138
hasExtraSrcRegAllocReq = 1, isCTI = 1, Defs = [AT], hasPostISelHook = 1 in {

0 commit comments

Comments
 (0)