forked from OSchip/llvm-project
Ban rematerializable instructions with side effects.
TableGen infers unmodeled side effects on instructions without a pattern. Fix some instruction definitions where that was overlooked. Also raise an error if a rematerializable instruction has unmodeled side effects. That doen't make any sense. llvm-svn: 141929
This commit is contained in:
parent
4c3e140247
commit
d9444d455e
|
@ -312,7 +312,7 @@ def tPICADD : TIt<(outs GPR:$dst), (ins GPR:$lhs, pclabel:$cp), IIC_iALUr, "",
|
||||||
// ADD <Rd>, sp, #<imm8>
|
// ADD <Rd>, sp, #<imm8>
|
||||||
// This is rematerializable, which is particularly useful for taking the
|
// This is rematerializable, which is particularly useful for taking the
|
||||||
// address of locals.
|
// address of locals.
|
||||||
let isReMaterializable = 1 in
|
let isReMaterializable = 1, neverHasSideEffects = 1 in
|
||||||
def tADDrSPi : T1pI<(outs tGPR:$dst), (ins GPRsp:$sp, t_imm0_1020s4:$imm),
|
def tADDrSPi : T1pI<(outs tGPR:$dst), (ins GPRsp:$sp, t_imm0_1020s4:$imm),
|
||||||
IIC_iALUi, "add", "\t$dst, $sp, $imm", []>,
|
IIC_iALUi, "add", "\t$dst, $sp, $imm", []>,
|
||||||
T1Encoding<{1,0,1,0,1,?}> {
|
T1Encoding<{1,0,1,0,1,?}> {
|
||||||
|
|
|
@ -442,17 +442,19 @@ let Predicates=[HasMul] in {
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
let canFoldAsLoad = 1, isReMaterializable = 1 in {
|
let canFoldAsLoad = 1, isReMaterializable = 1 in {
|
||||||
def LBU : LoadM<0x30, 0x000, "lbu ">;
|
let neverHasSideEffects = 1 in {
|
||||||
def LBUR : LoadM<0x30, 0x200, "lbur ">;
|
def LBU : LoadM<0x30, 0x000, "lbu ">;
|
||||||
|
def LBUR : LoadM<0x30, 0x200, "lbur ">;
|
||||||
|
|
||||||
def LHU : LoadM<0x31, 0x000, "lhu ">;
|
def LHU : LoadM<0x31, 0x000, "lhu ">;
|
||||||
def LHUR : LoadM<0x31, 0x200, "lhur ">;
|
def LHUR : LoadM<0x31, 0x200, "lhur ">;
|
||||||
|
|
||||||
def LW : LoadM<0x32, 0x000, "lw ">;
|
def LW : LoadM<0x32, 0x000, "lw ">;
|
||||||
def LWR : LoadM<0x32, 0x200, "lwr ">;
|
def LWR : LoadM<0x32, 0x200, "lwr ">;
|
||||||
|
|
||||||
let Defs = [CARRY] in {
|
let Defs = [CARRY] in {
|
||||||
def LWX : LoadM<0x32, 0x400, "lwx ">;
|
def LWX : LoadM<0x32, 0x400, "lwx ">;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def LBUI : LoadMI<0x38, "lbui ", zextloadi8>;
|
def LBUI : LoadMI<0x38, "lbui ", zextloadi8>;
|
||||||
|
|
|
@ -478,7 +478,7 @@ def MOV64rmm : RSYI<0x04EB,
|
||||||
"lmg\t{$from, $to, $dst}",
|
"lmg\t{$from, $to, $dst}",
|
||||||
[]>;
|
[]>;
|
||||||
|
|
||||||
let isReMaterializable = 1, isAsCheapAsAMove = 1,
|
let isReMaterializable = 1, neverHasSideEffects = 1, isAsCheapAsAMove = 1,
|
||||||
Constraints = "$src = $dst" in {
|
Constraints = "$src = $dst" in {
|
||||||
def MOV64Pr0_even : Pseudo<(outs GR64P:$dst), (ins GR64P:$src),
|
def MOV64Pr0_even : Pseudo<(outs GR64P:$dst), (ins GR64P:$src),
|
||||||
"lhi\t${dst:subreg_even}, 0",
|
"lhi\t${dst:subreg_even}, 0",
|
||||||
|
|
|
@ -967,7 +967,7 @@ let mayStore = 1 in
|
||||||
def MOV8mr_NOREX : I<0x88, MRMDestMem,
|
def MOV8mr_NOREX : I<0x88, MRMDestMem,
|
||||||
(outs), (ins i8mem_NOREX:$dst, GR8_NOREX:$src),
|
(outs), (ins i8mem_NOREX:$dst, GR8_NOREX:$src),
|
||||||
"mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
|
"mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
|
||||||
let mayLoad = 1,
|
let mayLoad = 1, neverHasSideEffects = 1,
|
||||||
canFoldAsLoad = 1, isReMaterializable = 1 in
|
canFoldAsLoad = 1, isReMaterializable = 1 in
|
||||||
def MOV8rm_NOREX : I<0x8A, MRMSrcMem,
|
def MOV8rm_NOREX : I<0x8A, MRMSrcMem,
|
||||||
(outs GR8_NOREX:$dst), (ins i8mem_NOREX:$src),
|
(outs GR8_NOREX:$dst), (ins i8mem_NOREX:$src),
|
||||||
|
|
|
@ -2829,6 +2829,12 @@ void CodeGenDAGPatterns::InferInstructionFlags() {
|
||||||
InstInfo.isBitcast = IsBitcast;
|
InstInfo.isBitcast = IsBitcast;
|
||||||
InstInfo.hasSideEffects = HasSideEffects;
|
InstInfo.hasSideEffects = HasSideEffects;
|
||||||
InstInfo.Operands.isVariadic = IsVariadic;
|
InstInfo.Operands.isVariadic = IsVariadic;
|
||||||
|
|
||||||
|
// Sanity checks.
|
||||||
|
if (InstInfo.isReMaterializable && InstInfo.hasSideEffects)
|
||||||
|
throw TGError(InstInfo.TheDef->getLoc(), "The instruction " +
|
||||||
|
InstInfo.TheDef->getName() +
|
||||||
|
" is rematerializable AND has unmodeled side effects?");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue