74 #define DEBUG_TYPE "mips-fastisel" 82 class MipsFastISel final :
public FastISel {
87 using BaseKind =
enum { RegBase, FrameIndexBase };
90 BaseKind
Kind = RegBase;
104 void setKind(BaseKind K) { Kind = K; }
105 BaseKind getKind()
const {
return Kind; }
106 bool isRegBase()
const {
return Kind == RegBase; }
107 bool isFIBase()
const {
return Kind == FrameIndexBase; }
109 void setReg(
unsigned Reg) {
110 assert(isRegBase() &&
"Invalid base register access!");
115 assert(isRegBase() &&
"Invalid base register access!");
119 void setFI(
unsigned FI) {
120 assert(isFIBase() &&
"Invalid base frame index access!");
124 unsigned getFI()
const {
125 assert(isFIBase() &&
"Invalid base frame index access!");
129 void setOffset(int64_t Offset_) { Offset = Offset_; }
146 bool fastLowerArguments()
override;
147 bool fastLowerCall(CallLoweringInfo &CLI)
override;
148 bool fastLowerIntrinsicCall(
const IntrinsicInst *II)
override;
150 bool UnsupportedFPMode;
164 bool selectFPToInt(
const Instruction *I,
bool IsSigned);
169 bool selectDivRem(
const Instruction *I,
unsigned ISDOpcode);
172 bool isTypeLegal(
Type *Ty,
MVT &VT);
173 bool isTypeSupported(
Type *Ty,
MVT &VT);
174 bool isLoadTypeLegal(
Type *Ty,
MVT &VT);
177 void simplifyAddress(
Address &Addr);
181 bool emitLoad(
MVT VT,
unsigned &ResultReg,
Address &Addr,
182 unsigned Alignment = 0);
183 bool emitStore(
MVT VT,
unsigned SrcReg,
Address Addr,
185 bool emitStore(
MVT VT,
unsigned SrcReg,
Address &Addr,
186 unsigned Alignment = 0);
187 unsigned emitIntExt(
MVT SrcVT,
unsigned SrcReg,
MVT DestVT,
bool isZExt);
188 bool emitIntExt(
MVT SrcVT,
unsigned SrcReg,
MVT DestVT,
unsigned DestReg,
191 bool emitIntZExt(
MVT SrcVT,
unsigned SrcReg,
MVT DestVT,
unsigned DestReg);
193 bool emitIntSExt(
MVT SrcVT,
unsigned SrcReg,
MVT DestVT,
unsigned DestReg);
194 bool emitIntSExt32r1(
MVT SrcVT,
unsigned SrcReg,
MVT DestVT,
196 bool emitIntSExt32r2(
MVT SrcVT,
unsigned SrcReg,
MVT DestVT,
199 unsigned getRegEnsuringSimpleIntegerWidening(
const Value *,
bool IsUnsigned);
201 unsigned emitLogicalOp(
unsigned ISDOpc,
MVT RetVT,
const Value *LHS,
208 unsigned materializeExternalCallSym(
MCSymbol *Syn);
211 return BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, TII.
get(Opc));
215 return BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, TII.
get(Opc),
220 unsigned MemReg, int64_t MemOffset) {
225 unsigned MemReg, int64_t MemOffset) {
226 return emitInst(Opc, DstReg).
addReg(MemReg).
addImm(MemOffset);
229 unsigned fastEmitInst_rr(
unsigned MachineInstOpcode,
231 unsigned Op0,
bool Op0IsKill,
232 unsigned Op1,
bool Op1IsKill);
237 unsigned Op0,
bool Op0IsKill, uint64_t imm1,
238 uint64_t imm2,
unsigned Op3,
bool Op3IsKill) {
247 bool finishCall(CallLoweringInfo &CLI,
MVT RetVT,
unsigned NumBytes);
265 unsigned fastMaterializeAlloca(
const AllocaInst *AI)
override;
266 unsigned fastMaterializeConstant(
const Constant *C)
override;
267 bool fastSelectInstruction(
const Instruction *I)
override;
269 #include "MipsGenFastISel.inc" 290 #include "MipsGenCallingConv.inc" 296 unsigned MipsFastISel::emitLogicalOp(
unsigned ISDOpc,
MVT RetVT,
299 if (isa<ConstantInt>(LHS) && !isa<ConstantInt>(RHS))
317 unsigned LHSReg = getRegForValue(LHS);
322 if (
const auto *
C = dyn_cast<ConstantInt>(RHS))
325 RHSReg = getRegForValue(RHS);
329 unsigned ResultReg = createResultReg(&Mips::GPR32RegClass);
333 emitInst(Opc, ResultReg).addReg(LHSReg).addReg(RHSReg);
337 unsigned MipsFastISel::fastMaterializeAlloca(
const AllocaInst *AI) {
339 "Alloca should always return a pointer.");
342 FuncInfo.StaticAllocaMap.find(AI);
344 if (SI != FuncInfo.StaticAllocaMap.
end()) {
345 unsigned ResultReg = createResultReg(&Mips::GPR32RegClass);
346 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
TII.get(Mips::LEA_ADDiu),
348 .addFrameIndex(SI->second)
356 unsigned MipsFastISel::materializeInt(
const Constant *
C,
MVT VT) {
364 unsigned MipsFastISel::materialize32BitInt(int64_t Imm,
366 unsigned ResultReg = createResultReg(RC);
369 unsigned Opc = Mips::ADDiu;
370 emitInst(Opc, ResultReg).addReg(Mips::ZERO).addImm(Imm);
373 emitInst(Mips::ORi, ResultReg).addReg(Mips::ZERO).addImm(Imm);
376 unsigned Lo = Imm & 0xFFFF;
377 unsigned Hi = (Imm >> 16) & 0xFFFF;
380 unsigned TmpReg = createResultReg(RC);
381 emitInst(Mips::LUi, TmpReg).addImm(Hi);
382 emitInst(Mips::ORi, ResultReg).addReg(TmpReg).addImm(Lo);
384 emitInst(Mips::LUi, ResultReg).addImm(Hi);
389 unsigned MipsFastISel::materializeFP(
const ConstantFP *CFP,
MVT VT) {
390 if (UnsupportedFPMode)
395 unsigned DestReg = createResultReg(RC);
396 unsigned TempReg = materialize32BitInt(Imm, &Mips::GPR32RegClass);
397 emitInst(Mips::MTC1, DestReg).addReg(TempReg);
401 unsigned DestReg = createResultReg(RC);
402 unsigned TempReg1 = materialize32BitInt(Imm >> 32, &Mips::GPR32RegClass);
404 materialize32BitInt(Imm & 0xFFFFFFFF, &Mips::GPR32RegClass);
411 unsigned MipsFastISel::materializeGV(
const GlobalValue *GV,
MVT VT) {
416 unsigned DestReg = createResultReg(RC);
422 emitInst(Mips::LW, DestReg)
423 .addReg(MFI->getGlobalBaseReg())
427 unsigned TempReg = createResultReg(RC);
428 emitInst(Mips::ADDiu, TempReg)
436 unsigned MipsFastISel::materializeExternalCallSym(
MCSymbol *Sym) {
438 unsigned DestReg = createResultReg(RC);
439 emitInst(Mips::LW, DestReg)
440 .addReg(MFI->getGlobalBaseReg())
447 unsigned MipsFastISel::fastMaterializeConstant(
const Constant *C) {
448 EVT CEVT = TLI.getValueType(DL, C->
getType(),
true);
455 if (
const ConstantFP *CFP = dyn_cast<ConstantFP>(C))
456 return (UnsupportedFPMode) ? 0 : materializeFP(CFP, VT);
457 else if (
const GlobalValue *GV = dyn_cast<GlobalValue>(C))
458 return materializeGV(GV, VT);
459 else if (isa<ConstantInt>(C))
460 return materializeInt(C, VT);
465 bool MipsFastISel::computeAddress(
const Value *Obj,
Address &Addr) {
466 const User *U =
nullptr;
467 unsigned Opcode = Instruction::UserOp1;
468 if (
const Instruction *
I = dyn_cast<Instruction>(Obj)) {
471 if (FuncInfo.StaticAllocaMap.count(static_cast<const AllocaInst *>(Obj)) ||
472 FuncInfo.MBBMap[
I->getParent()] == FuncInfo.MBB) {
473 Opcode =
I->getOpcode();
476 }
else if (
const ConstantExpr *C = dyn_cast<ConstantExpr>(Obj)) {
477 Opcode = C->getOpcode();
483 case Instruction::BitCast:
485 return computeAddress(U->
getOperand(0), Addr);
486 case Instruction::GetElementPtr: {
488 int64_t TmpOffset = Addr.getOffset();
497 unsigned Idx = cast<ConstantInt>(
Op)->getZExtValue();
502 if (
const ConstantInt *CI = dyn_cast<ConstantInt>(Op)) {
504 TmpOffset += CI->getSExtValue() * S;
507 if (canFoldAddIntoGEP(U, Op)) {
510 cast<ConstantInt>(cast<AddOperator>(
Op)->getOperand(1));
513 Op = cast<AddOperator>(
Op)->getOperand(0);
517 goto unsupported_gep;
522 Addr.setOffset(TmpOffset);
530 case Instruction::Alloca: {
533 FuncInfo.StaticAllocaMap.find(AI);
534 if (SI != FuncInfo.StaticAllocaMap.end()) {
535 Addr.setKind(Address::FrameIndexBase);
536 Addr.setFI(SI->second);
542 Addr.setReg(getRegForValue(Obj));
543 return Addr.getReg() != 0;
546 bool MipsFastISel::computeCallAddress(
const Value *V,
Address &Addr) {
547 const User *U =
nullptr;
548 unsigned Opcode = Instruction::UserOp1;
550 if (
const auto *
I = dyn_cast<Instruction>(V)) {
553 if (
I->getParent() == FuncInfo.MBB->getBasicBlock()) {
554 Opcode =
I->getOpcode();
557 }
else if (
const auto *C = dyn_cast<ConstantExpr>(V)) {
558 Opcode = C->getOpcode();
565 case Instruction::BitCast:
567 return computeCallAddress(U->
getOperand(0), Addr);
569 case Instruction::IntToPtr:
572 TLI.getPointerTy(DL))
573 return computeCallAddress(U->
getOperand(0), Addr);
575 case Instruction::PtrToInt:
577 if (TLI.getValueType(DL, U->
getType()) == TLI.getPointerTy(DL))
578 return computeCallAddress(U->
getOperand(0), Addr);
582 if (
const GlobalValue *GV = dyn_cast<GlobalValue>(V)) {
583 Addr.setGlobalValue(GV);
588 if (!Addr.getGlobalValue()) {
589 Addr.setReg(getRegForValue(V));
590 return Addr.getReg() != 0;
596 bool MipsFastISel::isTypeLegal(
Type *Ty,
MVT &VT) {
597 EVT evt = TLI.getValueType(DL, Ty,
true);
605 return TLI.isTypeLegal(VT);
608 bool MipsFastISel::isTypeSupported(
Type *Ty,
MVT &VT) {
612 if (isTypeLegal(Ty, VT))
623 bool MipsFastISel::isLoadTypeLegal(
Type *Ty,
MVT &VT) {
624 if (isTypeLegal(Ty, VT))
641 unsigned LeftReg = getRegEnsuringSimpleIntegerWidening(Left, IsUnsigned);
644 unsigned RightReg = getRegEnsuringSimpleIntegerWidening(
Right, IsUnsigned);
653 unsigned TempReg = createResultReg(&Mips::GPR32RegClass);
654 emitInst(
Mips::XOR, TempReg).addReg(LeftReg).addReg(RightReg);
655 emitInst(Mips::SLTiu, ResultReg).addReg(TempReg).addImm(1);
659 unsigned TempReg = createResultReg(&Mips::GPR32RegClass);
660 emitInst(
Mips::XOR, TempReg).addReg(LeftReg).addReg(RightReg);
661 emitInst(Mips::SLTu, ResultReg).addReg(Mips::ZERO).addReg(TempReg);
665 emitInst(Mips::SLTu, ResultReg).addReg(RightReg).addReg(LeftReg);
668 emitInst(Mips::SLTu, ResultReg).addReg(LeftReg).addReg(RightReg);
671 unsigned TempReg = createResultReg(&Mips::GPR32RegClass);
672 emitInst(Mips::SLTu, TempReg).addReg(LeftReg).addReg(RightReg);
673 emitInst(Mips::XORi, ResultReg).addReg(TempReg).addImm(1);
677 unsigned TempReg = createResultReg(&Mips::GPR32RegClass);
678 emitInst(Mips::SLTu, TempReg).addReg(RightReg).addReg(LeftReg);
679 emitInst(Mips::XORi, ResultReg).addReg(TempReg).addImm(1);
683 emitInst(Mips::SLT, ResultReg).addReg(RightReg).addReg(LeftReg);
686 emitInst(Mips::SLT, ResultReg).addReg(LeftReg).addReg(RightReg);
689 unsigned TempReg = createResultReg(&Mips::GPR32RegClass);
690 emitInst(Mips::SLT, TempReg).addReg(LeftReg).addReg(RightReg);
691 emitInst(Mips::XORi, ResultReg).addReg(TempReg).addImm(1);
695 unsigned TempReg = createResultReg(&Mips::GPR32RegClass);
696 emitInst(Mips::SLT, TempReg).addReg(RightReg).addReg(LeftReg);
697 emitInst(Mips::XORi, ResultReg).addReg(TempReg).addImm(1);
706 if (UnsupportedFPMode)
710 if (!IsFloat && !IsDouble)
712 unsigned Opc, CondMovOpc;
715 Opc = IsFloat ? Mips::C_EQ_S : Mips::C_EQ_D32;
716 CondMovOpc = Mips::MOVT_I;
719 Opc = IsFloat ? Mips::C_EQ_S : Mips::C_EQ_D32;
720 CondMovOpc = Mips::MOVF_I;
723 Opc = IsFloat ? Mips::C_OLT_S : Mips::C_OLT_D32;
724 CondMovOpc = Mips::MOVT_I;
727 Opc = IsFloat ? Mips::C_OLE_S : Mips::C_OLE_D32;
728 CondMovOpc = Mips::MOVT_I;
731 Opc = IsFloat ? Mips::C_ULE_S : Mips::C_ULE_D32;
732 CondMovOpc = Mips::MOVF_I;
735 Opc = IsFloat ? Mips::C_ULT_S : Mips::C_ULT_D32;
736 CondMovOpc = Mips::MOVF_I;
741 unsigned RegWithZero = createResultReg(&Mips::GPR32RegClass);
742 unsigned RegWithOne = createResultReg(&Mips::GPR32RegClass);
743 emitInst(Mips::ADDiu, RegWithZero).addReg(Mips::ZERO).addImm(0);
744 emitInst(Mips::ADDiu, RegWithOne).addReg(Mips::ZERO).addImm(1);
747 emitInst(CondMovOpc, ResultReg)
750 .addReg(RegWithZero);
757 bool MipsFastISel::emitLoad(
MVT VT,
unsigned &ResultReg,
Address &Addr,
758 unsigned Alignment) {
765 ResultReg = createResultReg(&Mips::GPR32RegClass);
769 ResultReg = createResultReg(&Mips::GPR32RegClass);
773 ResultReg = createResultReg(&Mips::GPR32RegClass);
777 if (UnsupportedFPMode)
779 ResultReg = createResultReg(&Mips::FGR32RegClass);
783 if (UnsupportedFPMode)
785 ResultReg = createResultReg(&Mips::AFGR64RegClass);
791 if (Addr.isRegBase()) {
792 simplifyAddress(Addr);
793 emitInstLoad(Opc, ResultReg, Addr.getReg(), Addr.getOffset());
796 if (Addr.isFIBase()) {
797 unsigned FI = Addr.getFI();
799 int64_t
Offset = Addr.getOffset();
804 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
TII.get(Opc), ResultReg)
813 bool MipsFastISel::emitStore(
MVT VT,
unsigned SrcReg,
Address &Addr,
814 unsigned Alignment) {
830 if (UnsupportedFPMode)
835 if (UnsupportedFPMode)
842 if (Addr.isRegBase()) {
843 simplifyAddress(Addr);
844 emitInstStore(Opc, SrcReg, Addr.getReg(), Addr.getOffset());
847 if (Addr.isFIBase()) {
848 unsigned FI = Addr.getFI();
850 int64_t
Offset = Addr.getOffset();
855 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
TII.get(Opc))
865 bool MipsFastISel::selectLogicalOp(
const Instruction *
I) {
867 if (!isTypeSupported(I->
getType(), VT))
874 case Instruction::And:
877 case Instruction::Or:
880 case Instruction::Xor:
888 updateValueMap(I, ResultReg);
892 bool MipsFastISel::selectLoad(
const Instruction *I) {
899 if (!isLoadTypeLegal(I->
getType(), VT))
908 if (!emitLoad(VT, ResultReg, Addr, cast<LoadInst>(I)->getAlignment()))
910 updateValueMap(I, ResultReg);
914 bool MipsFastISel::selectStore(
const Instruction *I) {
928 SrcReg = getRegForValue(Op0);
937 if (!emitStore(VT, SrcReg, Addr, cast<StoreInst>(I)->getAlignment()))
944 bool MipsFastISel::selectBranch(
const Instruction *I) {
959 unsigned ZExtCondReg = 0;
962 ZExtCondReg = createResultReg(&Mips::GPR32RegClass);
969 if (ZExtCondReg == 0) {
975 if (ZExtCondReg == 0)
979 BuildMI(*BrBB, FuncInfo.InsertPt, DbgLoc,
TII.get(Mips::BGTZ))
982 finishCondBranch(BI->
getParent(), TBB, FBB);
986 bool MipsFastISel::selectCmp(
const Instruction *I) {
987 const CmpInst *CI = cast<CmpInst>(
I);
988 unsigned ResultReg = createResultReg(&Mips::GPR32RegClass);
991 updateValueMap(I, ResultReg);
996 bool MipsFastISel::selectFPExt(
const Instruction *I) {
997 if (UnsupportedFPMode)
1000 EVT SrcVT = TLI.getValueType(DL, Src->
getType(),
true);
1001 EVT DestVT = TLI.getValueType(DL, I->
getType(),
true);
1007 getRegForValue(Src);
1012 unsigned DestReg = createResultReg(&Mips::AFGR64RegClass);
1013 emitInst(Mips::CVT_D32_S, DestReg).addReg(SrcReg);
1014 updateValueMap(I, DestReg);
1018 bool MipsFastISel::selectSelect(
const Instruction *I) {
1019 assert(isa<SelectInst>(I) &&
"Expected a select instruction.");
1024 if (!isTypeSupported(I->
getType(), VT) || UnsupportedFPMode) {
1026 dbgs() <<
".. .. gave up (!isTypeSupported || UnsupportedFPMode)\n");
1030 unsigned CondMovOpc;
1034 CondMovOpc = Mips::MOVN_I_I;
1035 RC = &Mips::GPR32RegClass;
1037 CondMovOpc = Mips::MOVN_I_S;
1038 RC = &Mips::FGR32RegClass;
1040 CondMovOpc = Mips::MOVN_I_D32;
1041 RC = &Mips::AFGR64RegClass;
1049 unsigned CondReg = getRegForValue(Cond);
1051 if (!Src1Reg || !Src2Reg || !CondReg)
1054 unsigned ZExtCondReg = createResultReg(&Mips::GPR32RegClass);
1061 unsigned ResultReg = createResultReg(RC);
1062 unsigned TempReg = createResultReg(RC);
1064 if (!ResultReg || !TempReg)
1067 emitInst(TargetOpcode::COPY, TempReg).addReg(Src2Reg);
1068 emitInst(CondMovOpc, ResultReg)
1069 .addReg(Src1Reg).addReg(ZExtCondReg).addReg(TempReg);
1070 updateValueMap(I, ResultReg);
1075 bool MipsFastISel::selectFPTrunc(
const Instruction *I) {
1076 if (UnsupportedFPMode)
1079 EVT SrcVT = TLI.getValueType(DL, Src->
getType(),
true);
1080 EVT DestVT = TLI.getValueType(DL, I->
getType(),
true);
1085 unsigned SrcReg = getRegForValue(Src);
1089 unsigned DestReg = createResultReg(&Mips::FGR32RegClass);
1093 emitInst(Mips::CVT_S_D32, DestReg).addReg(SrcReg);
1094 updateValueMap(I, DestReg);
1099 bool MipsFastISel::selectFPToInt(
const Instruction *I,
bool IsSigned) {
1100 if (UnsupportedFPMode)
1107 if (!isTypeLegal(DstTy, DstVT))
1115 if (!isTypeLegal(SrcTy, SrcVT))
1121 unsigned SrcReg = getRegForValue(Src);
1127 unsigned DestReg = createResultReg(&Mips::GPR32RegClass);
1128 unsigned TempReg = createResultReg(&Mips::FGR32RegClass);
1129 unsigned Opc = (SrcVT ==
MVT::f32) ? Mips::TRUNC_W_S : Mips::TRUNC_W_D32;
1132 emitInst(Opc, TempReg).addReg(SrcReg);
1133 emitInst(Mips::MFC1, DestReg).addReg(TempReg);
1135 updateValueMap(I, DestReg);
1139 bool MipsFastISel::processCallArgs(CallLoweringInfo &CLI,
1141 unsigned &NumBytes) {
1152 emitInst(Mips::ADJCALLSTACKDOWN).addImm(16).addImm(0);
1155 for (
unsigned i = 0,
e = ArgLocs.
size(); i !=
e; ++i) {
1165 if (Subtarget->isFP64bit())
1170 }
else if (i == 1) {
1175 if (Subtarget->isFP64bit())
1202 unsigned ArgReg = getRegForValue(ArgVal);
1214 ArgReg = emitIntExt(SrcVT, ArgReg, DestVT,
false);
1222 ArgReg = emitIntExt(SrcVT, ArgReg, DestVT,
true);
1233 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
1234 TII.get(TargetOpcode::COPY), VA.
getLocReg()).addReg(ArgReg);
1247 if (isa<UndefValue>(ArgVal))
1257 unsigned BEAlign = 0;
1258 if (ArgSize < 8 && !Subtarget->isLittle())
1259 BEAlign = 8 - ArgSize;
1262 Addr.setKind(Address::RegBase);
1263 Addr.setReg(Mips::SP);
1266 unsigned Alignment = DL.getABITypeAlignment(ArgVal->
getType());
1279 bool MipsFastISel::finishCall(CallLoweringInfo &CLI,
MVT RetVT,
1280 unsigned NumBytes) {
1282 emitInst(Mips::ADJCALLSTACKUP).addImm(16).addImm(0);
1288 CLI.Symbol ? CLI.Symbol->getName().data()
1292 if (RVLocs.
size() != 1)
1295 MVT CopyVT = RVLocs[0].getValVT();
1300 unsigned ResultReg = createResultReg(TLI.getRegClassFor(CopyVT));
1303 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
1304 TII.get(TargetOpcode::COPY),
1305 ResultReg).addReg(RVLocs[0].getLocReg());
1306 CLI.InRegs.push_back(RVLocs[0].getLocReg());
1308 CLI.ResultReg = ResultReg;
1309 CLI.NumResultRegs = 1;
1314 bool MipsFastISel::fastLowerArguments() {
1317 if (!FuncInfo.CanLowerReturn) {
1330 LLVM_DEBUG(
dbgs() <<
".. gave up (calling convention is not C)\n");
1334 std::array<MCPhysReg, 4> GPR32ArgRegs = {{Mips::A0, Mips::A1, Mips::A2,
1336 std::array<MCPhysReg, 2> FGR32ArgRegs = {{Mips::F12, Mips::F14}};
1337 std::array<MCPhysReg, 2> AFGR64ArgRegs = {{Mips::D6, Mips::D7}};
1338 auto NextGPR32 = GPR32ArgRegs.begin();
1339 auto NextFGR32 = FGR32ArgRegs.begin();
1340 auto NextAFGR64 = AFGR64ArgRegs.begin();
1342 struct AllocatedReg {
1346 : RC(RC),
Reg(Reg) {}
1352 for (
const auto &FormalArg : F->
args()) {
1353 if (FormalArg.hasAttribute(Attribute::InReg) ||
1354 FormalArg.hasAttribute(Attribute::StructRet) ||
1355 FormalArg.hasAttribute(Attribute::ByVal)) {
1360 Type *ArgTy = FormalArg.getType();
1366 EVT ArgVT = TLI.getValueType(DL, ArgTy);
1378 if (!FormalArg.hasAttribute(Attribute::SExt) &&
1379 !FormalArg.hasAttribute(Attribute::ZExt)) {
1382 LLVM_DEBUG(
dbgs() <<
".. .. gave up (i8/i16 arg is not extended)\n");
1386 if (NextGPR32 == GPR32ArgRegs.end()) {
1387 LLVM_DEBUG(
dbgs() <<
".. .. gave up (ran out of GPR32 arguments)\n");
1392 Allocation.
emplace_back(&Mips::GPR32RegClass, *NextGPR32++);
1395 NextFGR32 = FGR32ArgRegs.end();
1396 NextAFGR64 = AFGR64ArgRegs.end();
1400 if (FormalArg.hasAttribute(Attribute::ZExt)) {
1402 LLVM_DEBUG(
dbgs() <<
".. .. gave up (i32 arg is zero extended)\n");
1406 if (NextGPR32 == GPR32ArgRegs.end()) {
1407 LLVM_DEBUG(
dbgs() <<
".. .. gave up (ran out of GPR32 arguments)\n");
1412 Allocation.
emplace_back(&Mips::GPR32RegClass, *NextGPR32++);
1415 NextFGR32 = FGR32ArgRegs.end();
1416 NextAFGR64 = AFGR64ArgRegs.end();
1420 if (UnsupportedFPMode) {
1424 if (NextFGR32 == FGR32ArgRegs.end()) {
1425 LLVM_DEBUG(
dbgs() <<
".. .. gave up (ran out of FGR32 arguments)\n");
1429 Allocation.
emplace_back(&Mips::FGR32RegClass, *NextFGR32++);
1432 if (NextGPR32 != GPR32ArgRegs.end())
1434 if (NextAFGR64 != AFGR64ArgRegs.end())
1439 if (UnsupportedFPMode) {
1443 if (NextAFGR64 == AFGR64ArgRegs.end()) {
1444 LLVM_DEBUG(
dbgs() <<
".. .. gave up (ran out of AFGR64 arguments)\n");
1448 Allocation.
emplace_back(&Mips::AFGR64RegClass, *NextAFGR64++);
1451 if (NextGPR32 != GPR32ArgRegs.end())
1453 if (NextGPR32 != GPR32ArgRegs.end())
1455 if (NextFGR32 != FGR32ArgRegs.end())
1465 for (
const auto &FormalArg : F->
args()) {
1466 unsigned ArgNo = FormalArg.getArgNo();
1467 unsigned SrcReg = Allocation[ArgNo].Reg;
1468 unsigned DstReg = FuncInfo.MF->addLiveIn(SrcReg, Allocation[ArgNo].RC);
1472 unsigned ResultReg = createResultReg(Allocation[ArgNo].RC);
1473 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
1474 TII.get(TargetOpcode::COPY), ResultReg)
1476 updateValueMap(&FormalArg, ResultReg);
1481 unsigned IncomingArgSizeInBytes = 0;
1486 IncomingArgSizeInBytes = std::min(getABI().GetCalleeAllocdArgSizeInBytes(CC),
1487 IncomingArgSizeInBytes);
1495 bool MipsFastISel::fastLowerCall(CallLoweringInfo &CLI) {
1497 bool IsTailCall = CLI.IsTailCall;
1498 bool IsVarArg = CLI.IsVarArg;
1516 if (CLI.RetTy->isVoidTy())
1518 else if (!isTypeSupported(CLI.RetTy, RetVT))
1521 for (
auto Flag : CLI.OutFlags)
1527 OutVTs.
reserve(CLI.OutVals.size());
1529 for (
auto *Val : CLI.OutVals) {
1531 if (!isTypeLegal(Val->getType(), VT) &&
1543 if (!computeCallAddress(Callee, Addr))
1548 if (!processCallArgs(CLI, OutVTs, NumBytes))
1551 if (!Addr.getGlobalValue())
1555 unsigned DestAddress;
1557 DestAddress = materializeExternalCallSym(Symbol);
1559 DestAddress = materializeGV(Addr.getGlobalValue(),
MVT::i32);
1560 emitInst(TargetOpcode::COPY, Mips::T9).addReg(DestAddress);
1562 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
TII.get(Mips::JALR),
1566 for (
auto Reg : CLI.OutRegs)
1575 if (EmitJalrReloc && !Subtarget->inMips16Mode()) {
1581 MIB.
addSym(FuncInfo.MF->getContext().getOrCreateSymbol(
1586 return finishCall(CLI, RetVT, NumBytes);
1589 bool MipsFastISel::fastLowerIntrinsicCall(
const IntrinsicInst *II) {
1593 case Intrinsic::bswap: {
1597 if (!isTypeSupported(RetTy, VT))
1600 unsigned SrcReg = getRegForValue(II->
getOperand(0));
1603 unsigned DestReg = createResultReg(&Mips::GPR32RegClass);
1607 if (Subtarget->hasMips32r2()) {
1608 emitInst(Mips::WSBH, DestReg).addReg(SrcReg);
1609 updateValueMap(II, DestReg);
1612 unsigned TempReg[3];
1613 for (
int i = 0; i < 3; i++) {
1614 TempReg[i] = createResultReg(&Mips::GPR32RegClass);
1615 if (TempReg[i] == 0)
1618 emitInst(Mips::SLL, TempReg[0]).addReg(SrcReg).addImm(8);
1619 emitInst(
Mips::SRL, TempReg[1]).addReg(SrcReg).addImm(8);
1620 emitInst(
Mips::OR, TempReg[2]).addReg(TempReg[0]).addReg(TempReg[1]);
1621 emitInst(Mips::ANDi, DestReg).addReg(TempReg[2]).addImm(0xFFFF);
1622 updateValueMap(II, DestReg);
1626 if (Subtarget->hasMips32r2()) {
1627 unsigned TempReg = createResultReg(&Mips::GPR32RegClass);
1628 emitInst(Mips::WSBH, TempReg).addReg(SrcReg);
1629 emitInst(
Mips::ROTR, DestReg).addReg(TempReg).addImm(16);
1630 updateValueMap(II, DestReg);
1633 unsigned TempReg[8];
1634 for (
int i = 0; i < 8; i++) {
1635 TempReg[i] = createResultReg(&Mips::GPR32RegClass);
1636 if (TempReg[i] == 0)
1640 emitInst(
Mips::SRL, TempReg[0]).addReg(SrcReg).addImm(8);
1641 emitInst(
Mips::SRL, TempReg[1]).addReg(SrcReg).addImm(24);
1642 emitInst(Mips::ANDi, TempReg[2]).addReg(TempReg[0]).addImm(0xFF00);
1643 emitInst(
Mips::OR, TempReg[3]).addReg(TempReg[1]).addReg(TempReg[2]);
1645 emitInst(Mips::ANDi, TempReg[4]).addReg(SrcReg).addImm(0xFF00);
1646 emitInst(Mips::SLL, TempReg[5]).addReg(TempReg[4]).addImm(8);
1648 emitInst(Mips::SLL, TempReg[6]).addReg(SrcReg).addImm(24);
1649 emitInst(
Mips::OR, TempReg[7]).addReg(TempReg[3]).addReg(TempReg[5]);
1650 emitInst(
Mips::OR, DestReg).addReg(TempReg[6]).addReg(TempReg[7]);
1651 updateValueMap(II, DestReg);
1657 case Intrinsic::memcpy:
1658 case Intrinsic::memmove: {
1659 const auto *MTI = cast<MemTransferInst>(II);
1661 if (MTI->isVolatile())
1663 if (!MTI->getLength()->getType()->isIntegerTy(32))
1665 const char *IntrMemName = isa<MemCpyInst>(II) ?
"memcpy" :
"memmove";
1668 case Intrinsic::memset: {
1669 const MemSetInst *MSI = cast<MemSetInst>(II);
1681 bool MipsFastISel::selectRet(
const Instruction *I) {
1687 if (!FuncInfo.CanLowerReturn)
1708 CCInfo.AnalyzeReturn(Outs, RetCC);
1711 if (ValLocs.size() != 1)
1726 unsigned Reg = getRegForValue(RV);
1730 unsigned SrcReg = Reg + VA.
getValNo();
1733 if (!
MRI.getRegClass(SrcReg)->contains(DestReg))
1736 EVT RVEVT = TLI.getValueType(DL, RV->
getType());
1748 if (RVVT ==
MVT::f64 && UnsupportedFPMode) {
1755 if (RVVT != DestVT) {
1759 if (Outs[0].Flags.isZExt() || Outs[0].Flags.isSExt()) {
1760 bool IsZExt = Outs[0].Flags.isZExt();
1761 SrcReg = emitIntExt(RVVT, SrcReg, DestVT, IsZExt);
1768 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
1769 TII.get(TargetOpcode::COPY), DestReg).addReg(SrcReg);
1775 for (
unsigned i = 0,
e = RetRegs.
size(); i !=
e; ++i)
1780 bool MipsFastISel::selectTrunc(
const Instruction *I) {
1786 SrcVT = TLI.getValueType(DL, Op->
getType(),
true);
1787 DestVT = TLI.getValueType(DL, I->
getType(),
true);
1794 unsigned SrcReg = getRegForValue(Op);
1800 updateValueMap(I, SrcReg);
1804 bool MipsFastISel::selectIntExt(
const Instruction *I) {
1809 bool isZExt = isa<ZExtInst>(
I);
1810 unsigned SrcReg = getRegForValue(Src);
1814 EVT SrcEVT, DestEVT;
1815 SrcEVT = TLI.getValueType(DL, SrcTy,
true);
1816 DestEVT = TLI.getValueType(DL, DestTy,
true);
1824 unsigned ResultReg = createResultReg(&Mips::GPR32RegClass);
1826 if (!emitIntExt(SrcVT, SrcReg, DestVT, ResultReg, isZExt))
1828 updateValueMap(I, ResultReg);
1832 bool MipsFastISel::emitIntSExt32r1(
MVT SrcVT,
unsigned SrcReg,
MVT DestVT,
1845 unsigned TempReg = createResultReg(&Mips::GPR32RegClass);
1846 emitInst(Mips::SLL, TempReg).addReg(SrcReg).addImm(ShiftAmt);
1847 emitInst(
Mips::SRA, DestReg).addReg(TempReg).addImm(ShiftAmt);
1851 bool MipsFastISel::emitIntSExt32r2(
MVT SrcVT,
unsigned SrcReg,
MVT DestVT,
1857 emitInst(Mips::SEB, DestReg).addReg(SrcReg);
1860 emitInst(Mips::SEH, DestReg).addReg(SrcReg);
1866 bool MipsFastISel::emitIntSExt(
MVT SrcVT,
unsigned SrcReg,
MVT DestVT,
1870 if (Subtarget->hasMips32r2())
1871 return emitIntSExt32r2(SrcVT, SrcReg, DestVT, DestReg);
1872 return emitIntSExt32r1(SrcVT, SrcReg, DestVT, DestReg);
1875 bool MipsFastISel::emitIntZExt(
MVT SrcVT,
unsigned SrcReg,
MVT DestVT,
1893 emitInst(Mips::ANDi, DestReg).addReg(SrcReg).addImm(Imm);
1897 bool MipsFastISel::emitIntExt(
MVT SrcVT,
unsigned SrcReg,
MVT DestVT,
1898 unsigned DestReg,
bool IsZExt) {
1907 return emitIntZExt(SrcVT, SrcReg, DestVT, DestReg);
1908 return emitIntSExt(SrcVT, SrcReg, DestVT, DestReg);
1911 unsigned MipsFastISel::emitIntExt(
MVT SrcVT,
unsigned SrcReg,
MVT DestVT,
1913 unsigned DestReg = createResultReg(&Mips::GPR32RegClass);
1914 bool Success = emitIntExt(SrcVT, SrcReg, DestVT, DestReg, isZExt);
1915 return Success ? DestReg : 0;
1918 bool MipsFastISel::selectDivRem(
const Instruction *I,
unsigned ISDOpcode) {
1919 EVT DestEVT = TLI.getValueType(DL, I->
getType(),
true);
1928 switch (ISDOpcode) {
1941 unsigned Src0Reg = getRegForValue(I->
getOperand(0));
1942 unsigned Src1Reg = getRegForValue(I->
getOperand(1));
1943 if (!Src0Reg || !Src1Reg)
1946 emitInst(DivOpc).addReg(Src0Reg).addReg(Src1Reg);
1947 emitInst(Mips::TEQ).addReg(Src1Reg).addReg(Mips::ZERO).addImm(7);
1949 unsigned ResultReg = createResultReg(&Mips::GPR32RegClass);
1956 emitInst(MFOpc, ResultReg);
1958 updateValueMap(I, ResultReg);
1962 bool MipsFastISel::selectShift(
const Instruction *I) {
1965 if (!isTypeSupported(I->
getType(), RetVT))
1968 unsigned ResultReg = createResultReg(&Mips::GPR32RegClass);
1974 unsigned Op0Reg = getRegForValue(Op0);
1979 if (Opcode == Instruction::AShr || Opcode == Instruction::LShr) {
1980 unsigned TempReg = createResultReg(&Mips::GPR32RegClass);
1984 MVT Op0MVT = TLI.getValueType(DL, Op0->
getType(),
true).getSimpleVT();
1985 bool IsZExt = Opcode == Instruction::LShr;
1986 if (!emitIntExt(Op0MVT, Op0Reg,
MVT::i32, TempReg, IsZExt))
1992 if (
const auto *C = dyn_cast<ConstantInt>(I->
getOperand(1))) {
1993 uint64_t ShiftVal = C->getZExtValue();
1998 case Instruction::Shl:
2001 case Instruction::AShr:
2004 case Instruction::LShr:
2009 emitInst(Opcode, ResultReg).addReg(Op0Reg).addImm(ShiftVal);
2010 updateValueMap(I, ResultReg);
2014 unsigned Op1Reg = getRegForValue(I->
getOperand(1));
2021 case Instruction::Shl:
2022 Opcode = Mips::SLLV;
2024 case Instruction::AShr:
2025 Opcode = Mips::SRAV;
2027 case Instruction::LShr:
2028 Opcode = Mips::SRLV;
2032 emitInst(Opcode, ResultReg).addReg(Op0Reg).addReg(Op1Reg);
2033 updateValueMap(I, ResultReg);
2037 bool MipsFastISel::fastSelectInstruction(
const Instruction *I) {
2042 return selectLoad(I);
2044 return selectStore(I);
2045 case Instruction::SDiv:
2049 case Instruction::UDiv:
2053 case Instruction::SRem:
2057 case Instruction::URem:
2061 case Instruction::Shl:
2062 case Instruction::LShr:
2063 case Instruction::AShr:
2064 return selectShift(I);
2065 case Instruction::And:
2066 case Instruction::Or:
2067 case Instruction::Xor:
2068 return selectLogicalOp(I);
2069 case Instruction::Br:
2070 return selectBranch(I);
2072 return selectRet(I);
2073 case Instruction::Trunc:
2074 return selectTrunc(I);
2075 case Instruction::ZExt:
2076 case Instruction::SExt:
2077 return selectIntExt(I);
2078 case Instruction::FPTrunc:
2079 return selectFPTrunc(I);
2080 case Instruction::FPExt:
2081 return selectFPExt(I);
2082 case Instruction::FPToSI:
2083 return selectFPToInt(I,
true);
2084 case Instruction::FPToUI:
2085 return selectFPToInt(I,
false);
2086 case Instruction::ICmp:
2087 case Instruction::FCmp:
2088 return selectCmp(I);
2090 return selectSelect(I);
2095 unsigned MipsFastISel::getRegEnsuringSimpleIntegerWidening(
const Value *V,
2097 unsigned VReg = getRegForValue(V);
2100 MVT VMVT = TLI.getValueType(DL, V->
getType(),
true).getSimpleVT();
2106 unsigned TempReg = createResultReg(&Mips::GPR32RegClass);
2107 if (!emitIntExt(VMVT, VReg,
MVT::i32, TempReg, IsUnsigned))
2114 void MipsFastISel::simplifyAddress(
Address &Addr) {
2117 materialize32BitInt(Addr.getOffset(), &Mips::GPR32RegClass);
2118 unsigned DestReg = createResultReg(&Mips::GPR32RegClass);
2119 emitInst(Mips::ADDu, DestReg).addReg(TempReg).addReg(Addr.getReg());
2120 Addr.setReg(DestReg);
2125 unsigned MipsFastISel::fastEmitInst_rr(
unsigned MachineInstOpcode,
2127 unsigned Op0,
bool Op0IsKill,
2128 unsigned Op1,
bool Op1IsKill) {
2136 unsigned ResultReg = createResultReg(RC);
2140 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, II, ResultReg)
2156 return new MipsFastISel(funcInfo, libInfo);
TypeSize getStoreSize() const
Return the number of bytes overwritten by a store of the specified value type.
bool isVarArg() const
isVarArg - Return true if this function takes a variable number of arguments.
Return a value (possibly void), from a function.
FastISel * createFastISel(FunctionLoweringInfo &funcInfo, const TargetLibraryInfo *libInfo)
reference emplace_back(ArgTypes &&... Args)
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
bool isInteger() const
Return true if this is an integer or a vector integer type.
This class is the base class for the comparison instructions.
bool hasLocalLinkage() const
uint64_t getZExtValue() const
Get zero extended value.
unsigned constrainOperandRegClass(const MachineFunction &MF, const TargetRegisterInfo &TRI, MachineRegisterInfo &MRI, const TargetInstrInfo &TII, const RegisterBankInfo &RBI, MachineInstr &InsertPt, const TargetRegisterClass &RegClass, const MachineOperand &RegMO, unsigned OpIdx)
Constrain the Register operand OpIdx, so that it is now constrained to the TargetRegisterClass passed...
This class represents lattice values for constants.
Register getLocReg() const
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
bool isVector() const
Return true if this is a vector value type.
void push_back(const T &Elt)
TypeSize getSizeInBits() const
Returns the size of the specified MVT in bits.
Describe properties that are true of each instruction in the target description file.
MVT getSimpleVT() const
Return the SimpleValueType held in the specified simple EVT.
bool CCAssignFn(unsigned ValNo, MVT ValVT, MVT LocVT, CCValAssign::LocInfo LocInfo, ISD::ArgFlagsTy ArgFlags, CCState &State)
CCAssignFn - This function assigns a location for Val, updating State to reflect the change...
const MipsInstrInfo * getInstrInfo() const override
const Value * getTrueValue() const
0 1 0 0 True if ordered and less than
unsigned getValNo() const
LLVMContext & getContext() const
All values hold a context through their type.
1 1 1 0 True if unordered or not equal
This class wraps the llvm.memset intrinsic.
C - The default llvm calling convention, compatible with C.
BasicBlock * getSuccessor(unsigned i) const
constexpr bool isInt< 16 >(int64_t x)
unsigned const TargetRegisterInfo * TRI
Value * getCondition() const
bool isVectorTy() const
True if this is an instance of VectorType.
void reserve(size_type N)
Value * getLength() const
const MachineInstrBuilder & addMBB(MachineBasicBlock *MBB, unsigned TargetFlags=0) const
SI optimize exec mask operations pre RA
Used to lazily calculate structure layout information for a target machine, based on the DataLayout s...
A description of a memory reference used in the backend.
This class represents the LLVM 'select' instruction.
const HexagonInstrInfo * TII
PointerType * getType() const
Overload to return most specific pointer type.
Class to represent struct types.
A Use represents the edge between a Value definition and its users.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
bool isIntegerTy() const
True if this is an instance of IntegerType.
0 1 0 1 True if ordered and less than or equal
This file contains the simple types necessary to represent the attributes associated with functions a...
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted...
static bool CC_MipsO32_FP32(unsigned ValNo, MVT ValVT, MVT LocVT, CCValAssign::LocInfo LocInfo, ISD::ArgFlagsTy ArgFlags, CCState &State)
LocInfo getLocInfo() const
This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
This file implements a class to represent arbitrary precision integral constant values and operations...
This is a fast-path instruction selection class that generates poor code and doesn't support illegal ...
A constant value that is initialized with an expression using other constant values.
unsigned getNextStackOffset() const
getNextStackOffset - Return the next stack offset such that all stack slots satisfy their alignment r...
Type * getType() const
All values are typed, get the type of this value.
void AnalyzeCallResult(const SmallVectorImpl< ISD::InputArg > &Ins, CCAssignFn Fn, const Type *RetTy, const char *Func)
unsigned getOpcode() const
Returns a member of one of the enums like Instruction::Add.
AttributeList getAttributes() const
Return the attribute list for this Function.
static Error getOffset(const SymbolRef &Sym, SectionRef Sec, uint64_t &Result)
int64_t getObjectSize(int ObjectIdx) const
Return the size of the specified object.
Value * getOperand(unsigned i) const
unsigned getKillRegState(bool B)
Flag
These should be considered private to the implementation of the MCInstrDesc class.
TargetInstrInfo - Interface to description of machine instruction set.
bool isFloatTy() const
Return true if this is 'float', a 32-bit IEEE fp type.
static unsigned selectBinaryOp(unsigned GenericOpc, unsigned RegBankID, unsigned OpSize)
Select the AArch64 opcode for the basic binary operation GenericOpc (such as G_OR or G_SDIV)...
MachineInstrBuilder BuildMI(MachineFunction &MF, const DebugLoc &DL, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
Type * getReturnType() const
Returns the type of the ret val.
uint64_t getZExtValue() const
Return the constant as a 64-bit unsigned integer value after it has been zero extended as appropriate...
unsigned const MachineRegisterInfo * MRI
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
The instances of the Type class are immutable: once they are created, they are never changed...
This is an important class for using LLVM in a threaded context.
Conditional or Unconditional Branch instruction.
This is an important base class in LLVM.
This file contains the declarations for the subclasses of Constant, which represent the different fla...
ConstantFP - Floating Point Values [float, double].
bool hasInternalLinkage() const
#define LLVM_ATTRIBUTE_UNUSED
const MachineInstrBuilder & addRegMask(const uint32_t *Mask) const
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
std::string getEVTString() const
This function returns value type as a string, e.g. "i32".
const MachineInstrBuilder & addSym(MCSymbol *Sym, unsigned char TargetFlags=0) const
const MachineInstrBuilder & addFrameIndex(int Idx) const
const Value * getCondition() const
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function. ...
Type * getIndexedType() const
static bool isAtomic(Instruction *I)
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
This struct is a compact representation of a valid (non-zero power of two) alignment.
The memory access writes data.
const APFloat & getValueAPF() const
Intrinsic::ID getIntrinsicID() const
Return the intrinsic ID of this intrinsic.
void GetReturnInfo(CallingConv::ID CC, Type *ReturnType, AttributeList attr, SmallVectorImpl< ISD::OutputArg > &Outs, const TargetLowering &TLI, const DataLayout &DL)
Given an LLVM IR type and return type attributes, compute the return value EVTs and flags...
0 0 1 0 True if ordered and greater than
MO_GOT - Represents the offset into the global offset table at which the address the relocation entry...
unsigned getNumOperands() const
StructType * getStructTypeOrNull() const
CCState - This class holds information needed while lowering arguments and return values...
This is the shared class of boolean and integer constants.
CallingConv::ID getCallingConv() const
getCallingConv()/setCallingConv(CC) - These method get and set the calling convention of this functio...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Provides information about what library functions are available for the current target.
static bool CC_MipsO32(unsigned ValNo, MVT ValVT, MVT LocVT, CCValAssign::LocInfo LocInfo, ISD::ArgFlagsTy ArgFlags, CCState &State, ArrayRef< MCPhysReg > F64Regs)
CCValAssign - Represent assignment of one arg/retval to a location.
const MachineInstrBuilder & addMemOperand(MachineMemOperand *MMO) const
unsigned fastEmitInst_rr(unsigned MachineInstOpcode, const TargetRegisterClass *RC, unsigned Op0, bool Op0IsKill, unsigned Op1, bool Op1IsKill)
Emit a MachineInstr with two register operands and a result register in the given register class...
unsigned getNumDefs() const
Return the number of MachineOperands that are register definitions.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
static bool CC_Mips(unsigned ValNo, MVT ValVT, MVT LocVT, CCValAssign::LocInfo LocInfo, ISD::ArgFlagsTy ArgFlags, CCState &State) LLVM_ATTRIBUTE_UNUSED
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
amdgpu Simplify well known AMD library false FunctionCallee Callee
static unsigned getReg(const void *D, unsigned RC, unsigned RegNo)
This file defines the FastISel class.
const MipsTargetLowering * getTargetLowering() const override
void AnalyzeCallOperands(const SmallVectorImpl< ISD::OutputArg > &Outs, CCAssignFn Fn)
AnalyzeCallOperands - Analyze the outgoing arguments to a call, incorporating info about the passed v...
const Value * getFalseValue() const
The memory access reads data.
static MachinePointerInfo getFixedStack(MachineFunction &MF, int FI, int64_t Offset=0)
Return a MachinePointerInfo record that refers to the specified FrameIndex.
Predicate getPredicate() const
Return the predicate for this instruction.
uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
unsigned getNumArgOperands() const
bool isVector() const
Return true if this is a vector value type.
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
Bitwise operators - logical and, logical or, logical xor.
cl::opt< bool > EmitJalrReloc
uint64_t getElementOffset(unsigned Idx) const
unsigned getLocMemOffset() const
unsigned greater or equal
const MCInstrDesc & get(unsigned Opcode) const
Return the machine instruction descriptor that corresponds to the specified instruction opcode...
Function * getCalledFunction() const
Returns the function called, or null if this is an indirect function invocation.
const Function * getParent() const
Return the enclosing method, or null if none.
FunctionLoweringInfo - This contains information that is global to a function that is used when lower...
MipsFunctionInfo - This class is derived from MachineFunction private Mips target-specific informatio...
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
const LLVMTargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
constexpr bool isUInt< 16 >(uint64_t x)
static SDValue emitCmp(SelectionDAG &DAG, const SDLoc &DL, Comparison &C)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
0 0 0 1 True if ordered and equal
LLVM Value Representation.
Fast - This calling convention attempts to make calls as fast as possible (e.g.
bool useSoftFloat() const
Primary interface to the complete machine description for the target machine.
bool isThreadLocal() const
If the value is "Thread Local", its value isn't shared by the threads.
bool hasOneUse() const
Return true if there is exactly one user of this value.
static MachinePointerInfo getStack(MachineFunction &MF, int64_t Offset, uint8_t ID=0)
Stack pointer relative access.
APInt bitcastToAPInt() const
int64_t getSExtValue() const
Return the constant as a 64-bit integer value after it has been sign extended as appropriate for the ...
bool isSimple() const
Test if the given EVT is simple (as opposed to being extended).
0 0 1 1 True if ordered and greater than or equal
bool isDoubleTy() const
Return true if this is 'double', a 64-bit IEEE fp type.
const MachineInstrBuilder & addReg(Register RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
static bool CC_MipsO32_FP64(unsigned ValNo, MVT ValVT, MVT LocVT, CCValAssign::LocInfo LocInfo, ISD::ArgFlagsTy ArgFlags, CCState &State)
void convertToReg(unsigned RegNo)
iterator_range< arg_iterator > args()
Wrapper class representing virtual and physical registers.
bool isStructTy() const
True if this is an instance of StructType.
bool isArrayTy() const
True if this is an instance of ArrayType.
A wrapper class for inspecting calls to intrinsic functions.
This file describes how to lower LLVM code to machine code.
const BasicBlock * getParent() const
an instruction to allocate memory on the stack
Helper operand used to generate R_MIPS_JALR.
gep_type_iterator gep_type_begin(const User *GEP)