summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen
diff options
context:
space:
mode:
authorMatt Arsenault <Matthew.Arsenault@amd.com>2019-01-22 18:53:41 +0000
committerMatt Arsenault <Matthew.Arsenault@amd.com>2019-01-22 18:53:41 +0000
commita7cd83bc88b0a8cbd07b3dbe078e11a0a4e9e442 (patch)
treeb20ce4c56cdefb23e1667c8ca7e0f161dee3da36 /llvm/lib/CodeGen
parent4063cfc7451fb02b52b27e6298703743c7661cdd (diff)
downloadbcm5719-llvm-a7cd83bc88b0a8cbd07b3dbe078e11a0a4e9e442.tar.gz
bcm5719-llvm-a7cd83bc88b0a8cbd07b3dbe078e11a0a4e9e442.zip
GlobalISel: Disallow vectors for G_CONSTANT/G_FCONSTANT
llvm-svn: 351853
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r--llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp6
-rw-r--r--llvm/lib/CodeGen/MachineVerifier.cpp10
2 files changed, 12 insertions, 4 deletions
diff --git a/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp b/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp
index c964e98f578..6248a49317c 100644
--- a/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp
@@ -243,10 +243,8 @@ MachineInstrBuilder MachineIRBuilder::buildConstant(const DstOp &Res,
const ConstantInt &Val) {
LLT Ty = Res.getLLTTy(*getMRI());
- assert((Ty.isScalar() || Ty.isPointer()) && "invalid operand type");
-
const ConstantInt *NewVal = &Val;
- if (Ty.getSizeInBits() != Val.getBitWidth())
+ if (Ty.getScalarSizeInBits() != Val.getBitWidth())
NewVal = ConstantInt::get(getMF().getFunction().getContext(),
Val.getValue().sextOrTrunc(Ty.getSizeInBits()));
@@ -266,7 +264,7 @@ MachineInstrBuilder MachineIRBuilder::buildConstant(const DstOp &Res,
MachineInstrBuilder MachineIRBuilder::buildFConstant(const DstOp &Res,
const ConstantFP &Val) {
- assert(Res.getLLTTy(*getMRI()).isScalar() && "invalid operand type");
+ assert(!Res.getLLTTy(*getMRI()).isPointer() && "invalid operand type");
auto MIB = buildInstr(TargetOpcode::G_FCONSTANT);
Res.addDefToMIB(*getMRI(), MIB);
diff --git a/llvm/lib/CodeGen/MachineVerifier.cpp b/llvm/lib/CodeGen/MachineVerifier.cpp
index b7e0f575406..ad7825ba3eb 100644
--- a/llvm/lib/CodeGen/MachineVerifier.cpp
+++ b/llvm/lib/CodeGen/MachineVerifier.cpp
@@ -990,6 +990,16 @@ void MachineVerifier::visitMachineInstrBefore(const MachineInstr *MI) {
switch(MI->getOpcode()) {
default:
break;
+ case TargetOpcode::G_CONSTANT:
+ case TargetOpcode::G_FCONSTANT: {
+ if (MI->getNumOperands() < MCID.getNumOperands())
+ break;
+
+ LLT DstTy = MRI->getType(MI->getOperand(0).getReg());
+ if (DstTy.isVector())
+ report("Instruction cannot use a vector result type", MI);
+ break;
+ }
case TargetOpcode::G_LOAD:
case TargetOpcode::G_STORE:
// Generic loads and stores must have a single MachineMemOperand
OpenPOWER on IntegriCloud