mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-28 06:32:09 +00:00
Split fpscr into two registers: FPSCR and FPSCR_NZCV.
The fpscr register contains both flags (set by FP operations/comparisons) and control bits. The control bits (FPSCR) should be reserved, since they're always available and needn't be defined before use. The flag bits (FPSCR_NZCV) should like to be unreserved so they can be hoisted by MachineCSE. This fixes PR12165. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152076 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
923bb4117a
commit
4f92b5e616
@ -79,6 +79,7 @@ getReservedRegs(const MachineFunction &MF) const {
|
||||
BitVector Reserved(getNumRegs());
|
||||
Reserved.set(ARM::SP);
|
||||
Reserved.set(ARM::PC);
|
||||
Reserved.set(ARM::FPSCR);
|
||||
if (TFI->hasFP(MF))
|
||||
Reserved.set(FramePtr);
|
||||
if (hasBasePointer(MF))
|
||||
|
@ -1496,7 +1496,7 @@ bool ARMFastISel::SelectCmp(const Instruction *I) {
|
||||
Constant *Zero = ConstantInt::get(Type::getInt32Ty(*Context), 0);
|
||||
unsigned ZeroReg = TargetMaterializeConstant(Zero);
|
||||
bool isFloat = (Ty->isFloatTy() || Ty->isDoubleTy());
|
||||
unsigned CondReg = isFloat ? ARM::FPSCR : ARM::CPSR;
|
||||
unsigned CondReg = isFloat ? ARM::FPSCR_NZCV : ARM::CPSR;
|
||||
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, TII.get(MovCCOpc), DestReg)
|
||||
.addReg(ZeroReg).addImm(1)
|
||||
.addImm(ARMPred).addReg(CondReg);
|
||||
|
@ -294,7 +294,7 @@ def : Pat<(fmul (fneg SPR:$a), SPR:$b),
|
||||
(VNMULS SPR:$a, SPR:$b)>, Requires<[NoHonorSignDependentRounding]>;
|
||||
|
||||
// These are encoded as unary instructions.
|
||||
let Defs = [FPSCR] in {
|
||||
let Defs = [FPSCR_NZCV] in {
|
||||
def VCMPED : ADuI<0b11101, 0b11, 0b0100, 0b11, 0,
|
||||
(outs), (ins DPR:$Dd, DPR:$Dm),
|
||||
IIC_fpCMP64, "vcmpe", ".f64\t$Dd, $Dm",
|
||||
@ -323,7 +323,7 @@ def VCMPS : ASuI<0b11101, 0b11, 0b0100, 0b01, 0,
|
||||
// VFP pipelines on A8.
|
||||
let D = VFPNeonA8Domain;
|
||||
}
|
||||
} // Defs = [FPSCR]
|
||||
} // Defs = [FPSCR_NZCV]
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// FP Unary Operations.
|
||||
@ -343,7 +343,7 @@ def VABSS : ASuIn<0b11101, 0b11, 0b0000, 0b11, 0,
|
||||
let D = VFPNeonA8Domain;
|
||||
}
|
||||
|
||||
let Defs = [FPSCR] in {
|
||||
let Defs = [FPSCR_NZCV] in {
|
||||
def VCMPEZD : ADuI<0b11101, 0b11, 0b0101, 0b11, 0,
|
||||
(outs), (ins DPR:$Dd),
|
||||
IIC_fpCMP64, "vcmpe", ".f64\t$Dd, #0",
|
||||
@ -384,7 +384,7 @@ def VCMPZS : ASuI<0b11101, 0b11, 0b0101, 0b01, 0,
|
||||
// VFP pipelines on A8.
|
||||
let D = VFPNeonA8Domain;
|
||||
}
|
||||
} // Defs = [FPSCR]
|
||||
} // Defs = [FPSCR_NZCV]
|
||||
|
||||
def VCVTDS : ASuI<0b11101, 0b11, 0b0111, 0b11, 0,
|
||||
(outs DPR:$Dd), (ins SPR:$Sm),
|
||||
@ -1174,7 +1174,7 @@ class MovFromVFP<bits<4> opc19_16, dag oops, dag iops, string opc, string asm,
|
||||
|
||||
// APSR is the application level alias of CPSR. This FPSCR N, Z, C, V flags
|
||||
// to APSR.
|
||||
let Defs = [CPSR], Uses = [FPSCR], Rt = 0b1111 /* apsr_nzcv */ in
|
||||
let Defs = [CPSR], Uses = [FPSCR_NZCV], Rt = 0b1111 /* apsr_nzcv */ in
|
||||
def FMSTAT : MovFromVFP<0b0001 /* fpscr */, (outs), (ins),
|
||||
"vmrs", "\tapsr_nzcv, fpscr", [(arm_fmstat)]>;
|
||||
|
||||
|
@ -153,11 +153,16 @@ def Q15 : ARMReg<15, "q15", [D30, D31]>;
|
||||
}
|
||||
|
||||
// Current Program Status Register.
|
||||
def CPSR : ARMReg<0, "cpsr">;
|
||||
def APSR : ARMReg<1, "apsr">;
|
||||
def SPSR : ARMReg<2, "spsr">;
|
||||
def FPSCR : ARMReg<3, "fpscr">;
|
||||
def ITSTATE : ARMReg<4, "itstate">;
|
||||
// We model fpscr with two registers: FPSCR models the control bits and will be
|
||||
// reserved. FPSCR_NZCV models the flag bits and will be unreserved.
|
||||
def CPSR : ARMReg<0, "cpsr">;
|
||||
def APSR : ARMReg<1, "apsr">;
|
||||
def SPSR : ARMReg<2, "spsr">;
|
||||
def FPSCR : ARMReg<3, "fpscr">;
|
||||
def FPSCR_NZCV : ARMReg<3, "fpscr_nzcv"> {
|
||||
let Aliases = [FPSCR];
|
||||
}
|
||||
def ITSTATE : ARMReg<4, "itstate">;
|
||||
|
||||
// Special Registers - only available in privileged mode.
|
||||
def FPSID : ARMReg<0, "fpsid">;
|
||||
|
36
test/CodeGen/ARM/2012-03-05-FPSCR-bug.ll
Normal file
36
test/CodeGen/ARM/2012-03-05-FPSCR-bug.ll
Normal file
@ -0,0 +1,36 @@
|
||||
; RUN: llc -march=arm -mcpu=cortex-a8 -verify-machineinstrs < %s
|
||||
; PR12165
|
||||
target datalayout = "e-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-p:32:32:32-v128:32:32"
|
||||
target triple = "arm-none-linux"
|
||||
|
||||
define hidden void @_strtod_r() nounwind {
|
||||
br i1 undef, label %1, label %2
|
||||
|
||||
; <label>:1 ; preds = %0
|
||||
br label %2
|
||||
|
||||
; <label>:2 ; preds = %1, %0
|
||||
br i1 undef, label %3, label %8
|
||||
|
||||
; <label>:3 ; preds = %2
|
||||
br i1 undef, label %4, label %7
|
||||
|
||||
; <label>:4 ; preds = %3
|
||||
%5 = call i32 @llvm.flt.rounds()
|
||||
%6 = icmp eq i32 %5, 1
|
||||
br i1 %6, label %8, label %7
|
||||
|
||||
; <label>:7 ; preds = %4, %3
|
||||
unreachable
|
||||
|
||||
; <label>:8 ; preds = %4, %2
|
||||
br i1 undef, label %9, label %10
|
||||
|
||||
; <label>:9 ; preds = %8
|
||||
br label %10
|
||||
|
||||
; <label>:10 ; preds = %9, %8
|
||||
ret void
|
||||
}
|
||||
|
||||
declare i32 @llvm.flt.rounds() nounwind
|
Loading…
x
Reference in New Issue
Block a user