LLVM: include/llvm/CodeGen/FastISel.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

14#ifndef LLVM_CODEGEN_FASTISEL_H

15#define LLVM_CODEGEN_FASTISEL_H

16

29#include

30#include

31

32namespace llvm {

33

62

63

64

65

67public:

79

80

81

83

93

99

103

107 RetTy = ResultTy;

109

110 IsInReg = Call.hasRetAttr(Attribute::InReg);

112 IsVarArg = FuncTy->isVarArg();

114 RetSExt = Call.hasRetAttr(Attribute::SExt);

115 RetZExt = Call.hasRetAttr(Attribute::ZExt);

116

118 Args = std::move(ArgsList);

120

122

123 return *this;

124 }

125

129 unsigned FixedArgs = ~0U) {

130 RetTy = ResultTy;

133

134 IsInReg = Call.hasRetAttr(Attribute::InReg);

136 IsVarArg = FuncTy->isVarArg();

138 RetSExt = Call.hasRetAttr(Attribute::SExt);

139 RetZExt = Call.hasRetAttr(Attribute::ZExt);

140

142 Args = std::move(ArgsList);

143 NumFixedArgs = (FixedArgs == ~0U) ? FuncTy->getNumParams() : FixedArgs;

144

146

147 return *this;

148 }

149

152 unsigned FixedArgs = ~0U) {

153 RetTy = ResultTy;

156 Args = std::move(ArgsList);

158 return *this;

159 }

160

164 unsigned FixedArgs = ~0U);

165

168 unsigned FixedArgs = ~0U) {

169 RetTy = ResultTy;

172 Args = std::move(ArgsList);

174 return *this;

175 }

176

181

186

188

194

199 };

200

201protected:

216

217

218

219

220

222

223

224

225

227

228public:

230

231

232

234

235

236

241

242

243

245

246

248

249

251

252

253

254

256

257

258

259

261

262

263

264

266

267

268

270

271

272

273

275

276

277

279

280

281

282

283

284

285

286

287

288

289

290

291

293

294

295

296

297

298

299

304

305

306

308

309

312

314

315

316

318

319

321

322

323

325

326protected:

330

331

332

333

334

336

337

338

340

341

342

344

345

346

348

349

350

352

353

354

356

357

358

361

362

363

364

367

368

369

370

371

372

374 MVT ImmType);

375

376

377

379

380

381

382

385

386

387

390

391

392

395

396

397

401

402

403

407

408

409

413

414

415

419

420

421

425

426

427

431

432

433

436

437

438

440

441

442

444

445

446

448

449

450

453

454

455

456

457

458

459

460

462

464

465

466

467

469 unsigned OpNum);

470

471

472

476

477

481

482

483

487

488

489

490

491

492

493

494

496

497

499

501

504 unsigned NumArgs);

506

508

509

523

525

526 return MF->getFunction().hasOptSize();

527 }

528

529

530

533

534

535

538

539private:

540

541

542

543

544

545

546

547 bool handlePHINodesInSuccessorBlocks(const BasicBlock *LLVMBB);

548

549

550

552

553

554

555

557

558

559

560

561 void flushLocalValueMap();

562

563

564 void removeDeadLocalValueCode(MachineInstr *SavedLastLocalValue);

565

566

568

569

570

572 const CallInst *CI, unsigned StartIdx);

573 bool lowerCallOperands(const CallInst *CI, unsigned ArgIdx, unsigned NumArgs,

574 const Value *Callee, bool ForceRetVoidTy,

575 CallLoweringInfo &CLI);

576};

577

578}

579

580#endif

MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL

This file contains the simple types necessary to represent the attributes associated with functions a...

static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")

This file defines the DenseMap class.

const AbstractManglingParser< Derived, Alloc >::OperatorInfo AbstractManglingParser< Derived, Alloc >::Ops[]

Promote Memory to Register

uint64_t IntrinsicInst * II

static void addStackMapLiveVars(const CallBase &Call, unsigned StartIdx, const SDLoc &DL, SmallVectorImpl< SDValue > &Ops, SelectionDAGBuilder &Builder)

Add a stack map intrinsic call's live variable operands to a stackmap or patchpoint target node's ope...

This file defines the SmallVector class.

This file describes how to lower LLVM code to machine code.

an instruction to allocate memory on the stack

LLVM Basic Block Representation.

Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...

This class represents a function call, abstracting a target machine's calling convention.

This class is the base class for the comparison instructions.

Predicate

This enumeration lists the possible predicates for CmpInst subclasses.

ConstantFP - Floating Point Values [float, double].

This is an important base class in LLVM.

A parsed version of the target data layout string in and methods for querying it.

MachineRegisterInfo & MRI

Definition FastISel.h:205

const TargetLibraryInfo * LibInfo

Definition FastISel.h:214

const DataLayout & DL

Definition FastISel.h:210

bool selectGetElementPtr(const User *I)

void setLastLocalValue(MachineInstr *I)

Update the position of the last instruction emitted for materializing constants for use in the curren...

Definition FastISel.h:237

bool selectStackmap(const CallInst *I)

Register fastEmitInst_ri(unsigned MachineInstOpcode, const TargetRegisterClass *RC, Register Op0, uint64_t Imm)

Emit a MachineInstr with a register operand, an immediate, and a result register in the given registe...

bool selectExtractValue(const User *U)

DenseMap< const Value *, Register > LocalValueMap

Definition FastISel.h:202

void fastEmitBranch(MachineBasicBlock *MSucc, const DebugLoc &DbgLoc)

Emit an unconditional branch to the given block, unless it is the immediate (fall-through) successor,...

MachineInstr * EmitStartPt

The top most instruction in the current block that is allowed for emitting local variables.

Definition FastISel.h:226

bool selectXRayCustomEvent(const CallInst *II)

virtual Register fastEmit_r(MVT VT, MVT RetVT, unsigned Opcode, Register Op0)

This method is called by target-independent code to request that an instruction with the given type,...

Register fastEmitInst_(unsigned MachineInstOpcode, const TargetRegisterClass *RC)

Emit a MachineInstr with no operands and a result register in the given register class.

Register fastEmitInst_rr(unsigned MachineInstOpcode, const TargetRegisterClass *RC, Register Op0, Register Op1)

Emit a MachineInstr with two register operands and a result register in the given register class.

virtual Register fastEmit_rr(MVT VT, MVT RetVT, unsigned Opcode, Register Op0, Register Op1)

This method is called by target-independent code to request that an instruction with the given type,...

virtual bool fastLowerIntrinsicCall(const IntrinsicInst *II)

This method is called by target-independent code to do target- specific intrinsic lowering.

virtual bool lowerDbgDeclare(const Value *V, DIExpression *Expr, DILocalVariable *Var, const DebugLoc &DL)

Target-independent lowering of debug information.

MachineInstr * getLastLocalValue()

Return the position of the last instruction emitted for materializing constants for use in the curren...

Definition FastISel.h:233

bool lowerCall(const CallInst *I)

void leaveLocalValueArea(SavePoint Old)

Reset InsertPt to the given old insert position.

virtual Register fastMaterializeConstant(const Constant *C)

Emit a constant in a register using target-specific logic, such as constant pool loads.

Definition FastISel.h:473

Register fastEmitInst_rrr(unsigned MachineInstOpcode, const TargetRegisterClass *RC, Register Op0, Register Op1, Register Op2)

Emit a MachineInstr with three register operands and a result register in the given register class.

bool lowerCallTo(const CallInst *CI, MCSymbol *Symbol, unsigned NumArgs)

virtual Register fastEmit_i(MVT VT, MVT RetVT, unsigned Opcode, uint64_t Imm)

This method is called by target-independent code to request that an instruction with the given type,...

virtual Register fastEmit_f(MVT VT, MVT RetVT, unsigned Opcode, const ConstantFP *FPImm)

This method is called by target-independent code to request that an instruction with the given type,...

void handleDbgInfo(const Instruction *II)

Target-independent lowering of non-instruction debug info associated with this instruction.

bool selectFreeze(const User *I)

bool selectIntrinsicCall(const IntrinsicInst *II)

Register getRegForGEPIndex(MVT PtrVT, const Value *Idx)

This is a wrapper around getRegForValue that also takes care of truncating or sign-extending the give...

bool selectCast(const User *I, unsigned Opcode)

bool tryToFoldLoad(const LoadInst *LI, const Instruction *FoldInst)

We're checking to see if we can fold LI into FoldInst.

Register getRegForValue(const Value *V)

Create a virtual register and arrange for it to be assigned the value for the given LLVM value.

void removeDeadCode(MachineBasicBlock::iterator I, MachineBasicBlock::iterator E)

Remove all dead instructions between the I and E.

virtual Register fastMaterializeFloatZero(const ConstantFP *CF)

Emit the floating-point constant +0.0 in a register using target- specific logic.

Definition FastISel.h:484

void startNewBlock()

Set the current block to which generated machine instructions will be appended.

MachineMemOperand * createMachineMemOperandFor(const Instruction *I) const

Create a machine mem operand from the given instruction.

virtual bool tryToFoldLoadIntoMI(MachineInstr *, unsigned, const LoadInst *)

The specified machine instr operand is a vreg, and that vreg is being provided by the specified load ...

Definition FastISel.h:300

Register fastEmitInst_i(unsigned MachineInstOpcode, const TargetRegisterClass *RC, uint64_t Imm)

Emit a MachineInstr with a single immediate operand, and a result register in the given register clas...

Register fastEmitInst_rii(unsigned MachineInstOpcode, const TargetRegisterClass *RC, Register Op0, uint64_t Imm1, uint64_t Imm2)

Emit a MachineInstr with one register operand and two immediate operands.

MachineFrameInfo & MFI

Definition FastISel.h:206

MachineFunction * MF

Definition FastISel.h:204

bool canFoldAddIntoGEP(const User *GEP, const Value *Add)

Check if Add is an add that can be safely folded into GEP.

virtual bool lowerDbgValue(const Value *V, DIExpression *Expr, DILocalVariable *Var, const DebugLoc &DL)

Target-independent lowering of debug information.

TargetLoweringBase::ArgListTy ArgListTy

Definition FastISel.h:69

bool selectInstruction(const Instruction *I)

Do "fast" instruction selection for the given LLVM IR instruction and append the generated machine in...

virtual bool fastLowerCall(CallLoweringInfo &CLI)

This method is called by target-independent code to do target- specific call lowering.

bool selectXRayTypedEvent(const CallInst *II)

virtual Register fastMaterializeAlloca(const AllocaInst *C)

Emit an alloca address in a register using target-specific logic.

Definition FastISel.h:478

Register fastEmitZExtFromI1(MVT VT, Register Op0)

Emit MachineInstrs to compute the value of Op with all but the least significant bit set to zero.

DebugLoc getCurDebugLoc() const

Return current debug location information.

Definition FastISel.h:250

Register createResultReg(const TargetRegisterClass *RC)

virtual bool fastLowerArguments()

This method is called by target-independent code to do target- specific argument lowering.

bool selectFNeg(const User *I, const Value *In)

Emit an FNeg operation.

const TargetInstrInfo & TII

Definition FastISel.h:211

bool selectCall(const User *I)

Register lookUpRegForValue(const Value *V)

Look up the value to see if its value is already cached in a register.

CmpInst::Predicate optimizeCmpPredicate(const CmpInst *CI) const

virtual Register fastEmit_(MVT VT, MVT RetVT, unsigned Opcode)

This method is called by target-independent code to request that an instruction with the given type a...

void finishBasicBlock()

Flush the local value map.

Register fastEmitInst_r(unsigned MachineInstOpcode, const TargetRegisterClass *RC, Register Op0)

Emit a MachineInstr with one register operand and a result register in the given register class.

Register fastEmitInst_rri(unsigned MachineInstOpcode, const TargetRegisterClass *RC, Register Op0, Register Op1, uint64_t Imm)

Emit a MachineInstr with two register operands, an immediate, and a result register in the given regi...

FunctionLoweringInfo & FuncInfo

Definition FastISel.h:203

MachineConstantPool & MCP

Definition FastISel.h:207

bool selectOperator(const User *I, unsigned Opcode)

Do "fast" instruction selection for the given LLVM IR operator (Instruction or ConstantExpr),...

bool SkipTargetIndependentISel

Definition FastISel.h:215

Register fastEmitInst_f(unsigned MachineInstOpcode, const TargetRegisterClass *RC, const ConstantFP *FPImm)

Emit a MachineInstr with a floating point immediate, and a result register in the given register clas...

Register constrainOperandRegClass(const MCInstrDesc &II, Register Op, unsigned OpNum)

Try to constrain Op so that it is usable by argument OpNum of the provided MCInstrDesc.

MachineBasicBlock::iterator SavePoint

Definition FastISel.h:313

Register fastEmitInst_extractsubreg(MVT RetVT, Register Op0, uint32_t Idx)

Emit a MachineInstr for an extract_subreg from a specified index of a superregister to a specified ty...

void updateValueMap(const Value *I, Register Reg, unsigned NumRegs=1)

Update the value map to include the new mapping for this instruction, or insert an extra copy to get ...

bool selectBinaryOp(const User *I, unsigned ISDOpcode)

Select and emit code for a binary operator instruction, which has an opcode which directly correspond...

FastISel(FunctionLoweringInfo &FuncInfo, const TargetLibraryInfo *LibInfo, bool SkipTargetIndependentISel=false)

bool selectPatchpoint(const CallInst *I)

void recomputeInsertPt()

Reset InsertPt to prepare for inserting instructions into the current block.

virtual bool fastSelectInstruction(const Instruction *I)=0

This method is called by target-independent code when the normal FastISel process fails to select an ...

const TargetLowering & TLI

Definition FastISel.h:212

virtual Register fastEmit_ri(MVT VT, MVT RetVT, unsigned Opcode, Register Op0, uint64_t Imm)

This method is called by target-independent code to request that an instruction with the given type,...

bool shouldOptForSize(const MachineFunction *MF) const

Definition FastISel.h:524

const TargetMachine & TM

Definition FastISel.h:209

MIMetadata MIMD

Definition FastISel.h:208

MachineInstr * LastLocalValue

The position of the last instruction for materializing constants for use in the current block.

Definition FastISel.h:221

bool lowerArguments()

Do "fast" instruction selection for function arguments and append the machine instructions to the cur...

SavePoint enterLocalValueArea()

Prepare InsertPt to begin inserting instructions into the local value area and return the old insert ...

void finishCondBranch(const BasicBlock *BranchBB, MachineBasicBlock *TrueMBB, MachineBasicBlock *FalseMBB)

Emit an unconditional branch to FalseMBB, obtains the branch weight and adds TrueMBB and FalseMBB to ...

bool selectBitCast(const User *I)

Register fastEmit_ri_(MVT VT, unsigned Opcode, Register Op0, uint64_t Imm, MVT ImmType)

This method is a wrapper of fastEmit_ri.

const TargetRegisterInfo & TRI

Definition FastISel.h:213

TargetLoweringBase::ArgListEntry ArgListEntry

Definition FastISel.h:68

FunctionLoweringInfo - This contains information that is global to a function that is used when lower...

Class to represent function types.

A wrapper class for inspecting calls to intrinsic functions.

An instruction for reading from memory.

Context object for machine code objects.

Describe properties that are true of each instruction in the target description file.

MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...

MachineInstrBundleIterator< MachineInstr > iterator

The MachineConstantPool class keeps track of constants referenced by a function which must be spilled...

The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted.

Representation of each machine instruction.

A description of a memory reference used in the backend.

MachineOperand class - Representation of each machine instruction operand.

MachineRegisterInfo - Keep track of information for virtual and physical registers,...

Wrapper class representing virtual and physical registers.

This class consists of common code factored out of the SmallVector class to reduce code duplication b...

This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.

StringRef - Represent a constant reference to a string, i.e.

TargetInstrInfo - Interface to description of machine instruction set.

Provides information about what library functions are available for the current target.

std::vector< ArgListEntry > ArgListTy

This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...

Primary interface to the complete machine description for the target machine.

TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...

Target - Wrapper for Target specific information.

The instances of the Type class are immutable: once they are created, they are never changed.

LLVM Value Representation.

unsigned ID

LLVM IR allows to use arbitrary numbers as calling convention identifiers.

@ C

The default llvm calling convention, compatible with C.

This is an optimization pass for GlobalISel generic memory operations.

DWARFExpression::Operation Op

bool RetZExt

Definition FastISel.h:73

ArgListTy Args

Definition FastISel.h:88

bool IsReturnValueUsed

Definition FastISel.h:77

bool RetSExt

Definition FastISel.h:72

void clearOuts()

Definition FastISel.h:189

Register ResultReg

Definition FastISel.h:91

bool DoesNotReturn

Definition FastISel.h:76

CallingConv::ID CallConv

Definition FastISel.h:85

SmallVector< ISD::ArgFlagsTy, 16 > OutFlags

Definition FastISel.h:95

Type * RetTy

Definition FastISel.h:71

unsigned NumFixedArgs

Definition FastISel.h:84

SmallVector< Value *, 16 > OutVals

Definition FastISel.h:94

bool IsVarArg

Definition FastISel.h:74

unsigned NumResultRegs

Definition FastISel.h:92

CallLoweringInfo & setCallee(CallingConv::ID CC, Type *ResultTy, MCSymbol *Target, ArgListTy &&ArgsList, unsigned FixedArgs=~0U)

Definition FastISel.h:166

SmallVector< Register, 16 > OutRegs

Definition FastISel.h:96

bool IsTailCall

Definition FastISel.h:82

CallLoweringInfo()

Definition FastISel.h:100

const Value * Callee

Definition FastISel.h:86

CallLoweringInfo & setCallee(Type *ResultTy, FunctionType *FuncTy, MCSymbol *Target, ArgListTy &&ArgsList, const CallBase &Call, unsigned FixedArgs=~0U)

Definition FastISel.h:126

const CallBase * CB

Definition FastISel.h:89

CallLoweringInfo & setTailCall(bool Value=true)

Definition FastISel.h:177

MachineInstr * Call

Definition FastISel.h:90

bool IsPatchPoint

Definition FastISel.h:78

ArgListTy & getArgs()

Definition FastISel.h:187

CallLoweringInfo & setCallee(CallingConv::ID CC, Type *ResultTy, const Value *Target, ArgListTy &&ArgsList, unsigned FixedArgs=~0U)

Definition FastISel.h:150

bool IsInReg

Definition FastISel.h:75

void clearIns()

Definition FastISel.h:195

MCSymbol * Symbol

Definition FastISel.h:87

SmallVector< Register, 4 > InRegs

Definition FastISel.h:98

CallLoweringInfo & setIsPatchPoint(bool Value=true)

Definition FastISel.h:182

CallLoweringInfo & setCallee(Type *ResultTy, FunctionType *FuncTy, const Value *Target, ArgListTy &&ArgsList, const CallBase &Call)

Definition FastISel.h:104

SmallVector< ISD::InputArg, 4 > Ins

Definition FastISel.h:97