LLVM: lib/CodeGen/TypePromotion.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

41

42#define DEBUG_TYPE "type-promotion"

43#define PASS_NAME "Type Promotion"

44

45using namespace llvm;

46

49 cl::desc("Disable type promotion pass"));

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103namespace {

104class IRPromoter {

106 unsigned PromotedWidth = 0;

116

117 void ReplaceAllUsersOfWith(Value *From, Value *To);

118 void ExtendSources();

119 void ConvertTruncs();

120 void PromoteTree();

121 void TruncateSinks();

123

124public:

129 : Ctx(C), PromotedWidth(Width), Visited(visited), Sources(sources),

130 Sinks(sinks), SafeWrap(wrap), InstsToRemove(instsToRemove) {

132 }

133

134 void Mutate();

135};

136

137class TypePromotionImpl {

138 unsigned TypeSize = 0;

139 const TargetLowering *TLI = nullptr;

140 LLVMContext *Ctx = nullptr;

141 unsigned RegisterBitWidth = 0;

142 SmallPtrSet<Value *, 16> AllVisited;

143 SmallPtrSet<Instruction *, 8> SafeToPromote;

144 SmallPtrSet<Instruction *, 4> SafeWrap;

145 SmallPtrSet<Instruction *, 4> InstsToRemove;

146

147

148 bool EqualTypeSize(Value *V);

149

150 bool LessOrEqualTypeSize(Value *V);

151

152 bool GreaterThanTypeSize(Value *V);

153

154 bool LessThanTypeSize(Value *V);

155

156 bool isSource(Value *V);

157

158 bool isSink(Value *V);

159

160

161 bool shouldPromote(Value *V);

162

163

164 bool isSafeWrap(Instruction *I);

165

167

168

169 bool isSupportedValue(Value *V);

170

171

173 bool TryToPromote(Value *V, unsigned PromotedWidth, const LoopInfo &LI);

174

175public:

176 bool run(Function &F, const TargetMachine *TM,

177 const TargetTransformInfo &TTI, const LoopInfo &LI);

178};

179

180class TypePromotionLegacy : public FunctionPass {

181public:

182 static char ID;

183

184 TypePromotionLegacy() : FunctionPass(ID) {}

185

186 void getAnalysisUsage(AnalysisUsage &AU) const override {

188 AU.addRequired();

192 }

193

194 StringRef getPassName() const override { return PASS_NAME; }

195

197};

198

199}

200

202 unsigned Opc = I->getOpcode();

203 return Opc == Instruction::AShr || Opc == Instruction::SDiv ||

204 Opc == Instruction::SRem || Opc == Instruction::SExt;

205}

206

207bool TypePromotionImpl::EqualTypeSize(Value *V) {

208 return V->getType()->getScalarSizeInBits() == TypeSize;

209}

210

211bool TypePromotionImpl::LessOrEqualTypeSize(Value *V) {

212 return V->getType()->getScalarSizeInBits() <= TypeSize;

213}

214

215bool TypePromotionImpl::GreaterThanTypeSize(Value *V) {

216 return V->getType()->getScalarSizeInBits() > TypeSize;

217}

218

219bool TypePromotionImpl::LessThanTypeSize(Value *V) {

220 return V->getType()->getScalarSizeInBits() < TypeSize;

221}

222

223

224

225

226

227

228

229

230bool TypePromotionImpl::isSource(Value *V) {

232 return false;

233

234

236 return true;

238 return true;

242 return EqualTypeSize(Trunc);

243 return false;

244}

245

246

247

248

249bool TypePromotionImpl::isSink(Value *V) {

250

251

252

253

254

255

256

257

258

259

261 return LessOrEqualTypeSize(Store->getValueOperand());

263 return LessOrEqualTypeSize(Return->getReturnValue());

265 return GreaterThanTypeSize(ZExt);

267 return LessThanTypeSize(Switch->getCondition());

269 return ICmp->isSigned() || LessThanTypeSize(ICmp->getOperand(0));

270

272}

273

274

275bool TypePromotionImpl::isSafeWrap(Instruction *I) {

276

277

278

279

280

281

282

283

284

285

286

287

288

289

290

291

292

293

294

295

296

297

298

299

300

301

302

303

304

305

306

307

308

309

310

311

312

313

314

315

316

317

318

319

320

321

322

323

324

325

326

327

328

329 unsigned Opc = I->getOpcode();

330 if (Opc != Instruction::Add && Opc != Instruction::Sub)

331 return false;

332

333 if (I->hasOneUse() || isa<ICmpInst>(*I->user_begin()) ||

335 return false;

336

337

339 if (CI->isSigned() || CI->isEquality())

340 return false;

341

342 ConstantInt *ICmpConstant = nullptr;

344 ICmpConstant = Const;

346 ICmpConstant = Const;

347 else

348 return false;

349

350 const APInt &ICmpConst = ICmpConstant->getValue();

351 APInt OverflowConst = cast(I->getOperand(1))->getValue();

352 if (Opc == Instruction::Sub)

353 OverflowConst = -OverflowConst;

354

355

356

358

359

361 return false;

362

363 APInt NewConst = -((-OverflowConst).zext(64));

365 return false;

366 }

367

369

370 if (OverflowConst == 0 || OverflowConst.ugt(ICmpConst)) {

371 LLVM_DEBUG(dbgs() << "IR Promotion: Allowing safe overflow for "

372 << "const of " << *I << "\n");

373 return true;

374 }

375

376 LLVM_DEBUG(dbgs() << "IR Promotion: Allowing safe overflow for "

377 << "const of " << *I << " and " << *CI << "\n");

379 return true;

380}

381

382bool TypePromotionImpl::shouldPromote(Value *V) {

384 return false;

385

386 if (isSource(V))

387 return true;

388

390 if (I)

391 return false;

392

394 return false;

395

396 return true;

397}

398

399

400

403 return false;

404

406 return true;

407

408 return I->hasNoUnsignedWrap();

409}

410

411void IRPromoter::ReplaceAllUsersOfWith(Value *From, Value *To) {

412 SmallVector<Instruction *, 4> Users;

414 bool ReplacedAll = true;

415

416 LLVM_DEBUG(dbgs() << "IR Promotion: Replacing " << *From << " with " << *To

417 << "\n");

418

419 for (Use &U : From->uses()) {

421 if (InstTo && User->isIdenticalTo(InstTo)) {

422 ReplacedAll = false;

423 continue;

424 }

425 Users.push_back(User);

426 }

427

428 for (auto *U : Users)

429 U->replaceUsesOfWith(From, To);

430

431 if (ReplacedAll)

434}

435

436void IRPromoter::ExtendSources() {

438

440 assert(V->getType() != ExtTy && "zext already extends to i32");

441 LLVM_DEBUG(dbgs() << "IR Promotion: Inserting ZExt for " << *V << "\n");

445

449 I->moveBefore(InsertPt);

450 else

451 I->moveAfter(&*InsertPt);

452 NewInsts.insert(I);

453 }

454

455 ReplaceAllUsersOfWith(V, ZExt);

456 };

457

458

459 LLVM_DEBUG(dbgs() << "IR Promotion: Promoting sources:\n");

460 for (auto *V : Sources) {

463 InsertZExt(I, I->getIterator());

465 BasicBlock &BB = Arg->getParent()->front();

467 } else {

469 }

470 Promoted.insert(V);

471 }

472}

473

474void IRPromoter::PromoteTree() {

475 LLVM_DEBUG(dbgs() << "IR Promotion: Mutating the tree..\n");

476

477

478

479 for (auto *V : Visited) {

480 if (Sources.count(V))

481 continue;

482

485 continue;

486

487 for (unsigned i = 0, e = I->getNumOperands(); i < e; ++i) {

488 Value *Op = I->getOperand(i);

490 continue;

491

493

494

495

496

497

498

499 APInt NewConst;

501 if (I->getOpcode() == Instruction::ICmp)

502 NewConst = -((-Const->getValue()).zext(PromotedWidth));

503 else if (I->getOpcode() == Instruction::Add && i == 1)

504 NewConst = -((-Const->getValue()).zext(PromotedWidth));

505 else

506 NewConst = Const->getValue().zext(PromotedWidth);

507 } else

508 NewConst = Const->getValue().zext(PromotedWidth);

509

510 I->setOperand(i, ConstantInt::get(Const->getContext(), NewConst));

512 I->setOperand(i, ConstantInt::get(ExtTy, 0));

513 }

514

515

517 I->mutateType(ExtTy);

518 Promoted.insert(I);

519 }

520 }

521}

522

523void IRPromoter::TruncateSinks() {

524 LLVM_DEBUG(dbgs() << "IR Promotion: Fixing up the sinks:\n");

525

527

528 auto InsertTrunc = [&](Value *V, Type *TruncTy) -> Instruction * {

530 return nullptr;

531

532 if ((!Promoted.count(V) && !NewInsts.count(V)) || Sources.count(V))

533 return nullptr;

534

535 LLVM_DEBUG(dbgs() << "IR Promotion: Creating " << *TruncTy << " Trunc for "

536 << *V << "\n");

539 if (Trunc)

540 NewInsts.insert(Trunc);

541 return Trunc;

542 };

543

544

545

546 for (auto *I : Sinks) {

547 LLVM_DEBUG(dbgs() << "IR Promotion: For Sink: " << *I << "\n");

548

549

551 for (unsigned i = 0; i < Call->arg_size(); ++i) {

553 Type *Ty = TruncTysMap[Call][i];

554 if (Instruction *Trunc = InsertTrunc(Arg, Ty)) {

557 }

558 }

559 continue;

560 }

561

562

565 if (Instruction *Trunc = InsertTrunc(Switch->getCondition(), Ty)) {

566 Trunc->moveBefore(Switch->getIterator());

567 Switch->setCondition(Trunc);

568 }

569 continue;

570 }

571

572

573

574

575

576

577

580 continue;

581

582

583 for (unsigned i = 0; i < I->getNumOperands(); ++i) {

584 Type *Ty = TruncTysMap[I][i];

585 if (Instruction *Trunc = InsertTrunc(I->getOperand(i), Ty)) {

586 Trunc->moveBefore(I->getIterator());

587 I->setOperand(i, Trunc);

588 }

589 }

590 }

591}

592

593void IRPromoter::Cleanup() {

595

596

597 for (auto *V : Visited) {

599 continue;

600

602 if (ZExt->getDestTy() != ExtTy)

603 continue;

604

605 Value *Src = ZExt->getOperand(0);

606 if (ZExt->getSrcTy() == ZExt->getDestTy()) {

607 LLVM_DEBUG(dbgs() << "IR Promotion: Removing unnecessary cast: " << *ZExt

608 << "\n");

609 ReplaceAllUsersOfWith(ZExt, Src);

610 continue;

611 }

612

613

614

617 assert(Trunc->getOperand(0)->getType() == ExtTy &&

618 "expected inserted trunc to be operating on i32");

619 ReplaceAllUsersOfWith(ZExt, Trunc->getOperand(0));

620 }

621 }

622

623 for (auto *I : InstsToRemove) {

624 LLVM_DEBUG(dbgs() << "IR Promotion: Removing " << *I << "\n");

625 I->dropAllReferences();

626 }

627}

628

629void IRPromoter::ConvertTruncs() {

630 LLVM_DEBUG(dbgs() << "IR Promotion: Converting truncs..\n");

632

633 for (auto *V : Visited) {

635 continue;

636

639 IntegerType *SrcTy = cast(Trunc->getOperand(0)->getType());

641

643 ConstantInt *Mask =

648

650 NewInsts.insert(I);

651

652 ReplaceAllUsersOfWith(Trunc, Masked);

653 }

654}

655

656void IRPromoter::Mutate() {

657 LLVM_DEBUG(dbgs() << "IR Promotion: Promoting use-def chains to "

658 << PromotedWidth << "-bits\n");

659

660

661 for (auto *I : Sinks) {

664 TruncTysMap[Call].push_back(Arg->getType());

666 TruncTysMap[I].push_back(Switch->getCondition()->getType());

667 else {

668 for (const Value *Op : I->operands())

669 TruncTysMap[I].push_back(Op->getType());

670 }

671 }

672 for (auto *V : Visited) {

674 continue;

676 TruncTysMap[Trunc].push_back(Trunc->getDestTy());

677 }

678

679

680 ExtendSources();

681

682

683 PromoteTree();

684

685

686 ConvertTruncs();

687

688

689 TruncateSinks();

690

691

692

694

695 LLVM_DEBUG(dbgs() << "IR Promotion: Mutation complete\n");

696}

697

698

699

700

701bool TypePromotionImpl::isSupportedType(Value *V) {

702 Type *Ty = V->getType();

703

704

706 return true;

707

710 return false;

711

712 return LessOrEqualTypeSize(V);

713}

714

715

716

717

718

719bool TypePromotionImpl::isSupportedValue(Value *V) {

721 switch (I->getOpcode()) {

722 default:

725 case Instruction::GetElementPtr:

726 case Instruction::Store:

727 case Instruction::Br:

728 case Instruction::Switch:

729 return true;

730 case Instruction::PHI:

731 case Instruction::Select:

732 case Instruction::Ret:

733 case Instruction::Load:

734 case Instruction::Trunc:

736 case Instruction::BitCast:

737 return I->getOperand(0)->getType() == I->getType();

738 case Instruction::ZExt:

740 case Instruction::ICmp:

741

742

743

744

746 return true;

747 return EqualTypeSize(I->getOperand(0));

748 case Instruction::Call: {

749

750

751

755 }

756 }

761

763}

764

765

766

767

768bool TypePromotionImpl::isLegalToPromote(Value *V) {

770 if (I)

771 return true;

772

773 if (SafeToPromote.count(I))

774 return true;

775

777 SafeToPromote.insert(I);

778 return true;

779 }

780 return false;

781}

782

783bool TypePromotionImpl::TryToPromote(Value *V, unsigned PromotedWidth,

784 const LoopInfo &LI) {

785 Type *OrigTy = V->getType();

787 SafeToPromote.clear();

788 SafeWrap.clear();

789

790 if (!isSupportedValue(V) || !shouldPromote(V) || isLegalToPromote(V))

791 return false;

792

793 LLVM_DEBUG(dbgs() << "IR Promotion: TryToPromote: " << *V << ", from "

794 << TypeSize << " bits to " << PromotedWidth << "\n");

795

796 SetVector<Value *> WorkList;

797 SetVector<Value *> Sources;

798 SetVector<Instruction *> Sinks;

799 SetVector<Value *> CurrentVisited;

801

802

803

804

805 auto AddLegalInst = [&](Value *V) {

806 if (CurrentVisited.count(V))

807 return true;

808

809

810

812 return false;

813

814 if (!isSupportedValue(V) || (shouldPromote(V) && isLegalToPromote(V))) {

815 LLVM_DEBUG(dbgs() << "IR Promotion: Can't handle: " << *V << "\n");

816 return false;

817 }

818

820 return true;

821 };

822

823

824 while (!WorkList.empty()) {

826 if (CurrentVisited.count(V))

827 continue;

828

829

831 continue;

832

833

834

835

836

837 if (!AllVisited.insert(V).second)

838 return false;

839

840 CurrentVisited.insert(V);

841

842

843 if (isSink(V))

845

846 if (isSource(V))

848

849 if (!isSink(V) && !isSource(V)) {

851

852 for (auto &U : I->operands()) {

853 if (!AddLegalInst(U))

854 return false;

855 }

856 }

857 }

858

859

860

861 if (isSource(V) || shouldPromote(V)) {

862 for (Use &U : V->uses()) {

863 if (!AddLegalInst(U.getUser()))

864 return false;

865 }

866 }

867 }

868

870 dbgs() << "IR Promotion: Visited nodes:\n";

871 for (auto *I : CurrentVisited)

872 I->dump();

873 });

874

875 unsigned ToPromote = 0;

876 unsigned NonFreeArgs = 0;

877 unsigned NonLoopSources = 0, LoopSinks = 0;

878 SmallPtrSet<BasicBlock *, 4> Blocks;

879 for (auto *CV : CurrentVisited) {

881 Blocks.insert(I->getParent());

882

883 if (Sources.count(CV)) {

885 if (!Arg->hasZExtAttr() && !Arg->hasSExtAttr())

886 ++NonFreeArgs;

889 ++NonLoopSources;

890 continue;

891 }

892

894 continue;

896 ++LoopSinks;

898 continue;

899 ++ToPromote;

900 }

901

902

903

904 if (isa<PHINode>(V) && !(LoopSinks && NonLoopSources) &&

905 (ToPromote < 2 || (Blocks.size() == 1 && NonFreeArgs > SafeWrap.size())))

906 return false;

907

908 IRPromoter Promoter(*Ctx, PromotedWidth, CurrentVisited, Sources, Sinks,

909 SafeWrap, InstsToRemove);

910 Promoter.Mutate();

911 return true;

912}

913

914bool TypePromotionImpl::run(Function &F, const TargetMachine *TM,

915 const TargetTransformInfo &TTI,

916 const LoopInfo &LI) {

918 return false;

919

920 LLVM_DEBUG(dbgs() << "IR Promotion: Running on " << F.getName() << "\n");

921

922 AllVisited.clear();

923 SafeToPromote.clear();

924 SafeWrap.clear();

925 bool MadeChange = false;

926 const DataLayout &DL = F.getDataLayout();

927 const TargetSubtargetInfo *SubtargetInfo = TM->getSubtargetImpl(F);

929 RegisterBitWidth =

931 Ctx = &F.getContext();

932

933

934

935 auto GetPromoteWidth = [&](Instruction *I) -> uint32_t {

937 return 0;

938

941 return 0;

942

943 if (TLI->getTypeAction(*Ctx, SrcVT) != TargetLowering::TypePromoteInteger)

944 return 0;

945

948 return 0;

950 LLVM_DEBUG(dbgs() << "IR Promotion: Couldn't find target register "

951 << "for promoted type\n");

952 return 0;

953 }

954

955

957 };

958

959 auto BBIsInLoop = [&](BasicBlock *BB) -> bool {

960 for (auto *L : LI)

961 if (L->contains(BB))

962 return true;

963 return false;

964 };

965

966 for (BasicBlock &BB : F) {

967 for (Instruction &I : BB) {

968 if (AllVisited.count(&I))

969 continue;

970

973 LLVM_DEBUG(dbgs() << "IR Promotion: Searching from: "

974 << *I.getOperand(0) << "\n");

978 if (RegisterBitWidth < PromoteWidth) {

979 LLVM_DEBUG(dbgs() << "IR Promotion: Couldn't find target "

980 << "register for ZExt type\n");

981 continue;

982 }

983 MadeChange |= TryToPromote(Phi, PromoteWidth, LI);

985

986

987 if (ICmp->isSigned())

988 continue;

989

990 LLVM_DEBUG(dbgs() << "IR Promotion: Searching from: " << *ICmp << "\n");

991

992 for (auto &Op : ICmp->operands()) {

994 if (auto PromotedWidth = GetPromoteWidth(OpI)) {

995 MadeChange |= TryToPromote(OpI, PromotedWidth, LI);

996 break;

997 }

998 }

999 }

1000 }

1001 }

1002 if (!InstsToRemove.empty()) {

1003 for (auto *I : InstsToRemove)

1004 I->eraseFromParent();

1005 InstsToRemove.clear();

1006 }

1007 }

1008

1009 AllVisited.clear();

1010 SafeToPromote.clear();

1011 SafeWrap.clear();

1012

1013 return MadeChange;

1014}

1015

1021

1022char TypePromotionLegacy::ID = 0;

1023

1024bool TypePromotionLegacy::runOnFunction(Function &F) {

1025 if (skipFunction(F))

1026 return false;

1027

1028 auto &TPC = getAnalysis();

1029 auto *TM = &TPC.getTM();

1030 auto &TTI = getAnalysis().getTTI(F);

1031 auto &LI = getAnalysis().getLoopInfo();

1032

1033 TypePromotionImpl TP;

1034 return TP.run(F, TM, TTI, LI);

1035}

1036

1038 return new TypePromotionLegacy();

1039}

1040

1045 TypePromotionImpl TP;

1046

1050

1054 return PA;

1055}

assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")

static bool isSupportedType(const DataLayout &DL, const ARMTargetLowering &TLI, Type *T)

MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL

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

This file contains the declarations for the subclasses of Constant, which represent the different fla...

static bool runOnFunction(Function &F, bool PostInlining)

static const HTTPClientCleanup Cleanup

iv Induction Variable Users

#define INITIALIZE_PASS_DEPENDENCY(depName)

#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)

#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)

This file implements a set that has insertion order iteration characteristics.

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

Target-Independent Code Generator Pass Configuration Options pass.

This pass exposes codegen information to IR-level passes.

static unsigned getBitWidth(Type *Ty, const DataLayout &DL)

Returns the bitwidth of the given scalar or pointer type.

static APInt getMaxValue(unsigned numBits)

Gets maximum unsigned value of APInt for specific bit width.

bool ugt(const APInt &RHS) const

Unsigned greater than comparison.

unsigned getBitWidth() const

Return the number of bits in the APInt.

bool isNonPositive() const

Determine if this APInt Value is non-positive (<= 0).

int64_t getSExtValue() const

Get sign extended value.

PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)

Get the result of an analysis pass for a given IR unit.

AnalysisUsage & addRequired()

AnalysisUsage & addPreserved()

Add the specified Pass class to the set of analyses preserved by this pass.

LLVM_ABI void setPreservesCFG()

This function should be called by the pass, iff they do not:

LLVM_ABI const_iterator getFirstInsertionPt() const

Returns an iterator to the first instruction in this block that is suitable for inserting a non-PHI i...

InstListType::iterator iterator

Instruction iterators...

Represents analyses that only rely on functions' control flow.

bool hasRetAttr(Attribute::AttrKind Kind) const

Determine whether the return value has the given attribute.

Value * getArgOperand(unsigned i) const

void setArgOperand(unsigned i, Value *v)

iterator_range< User::op_iterator > args()

Iteration adapter for range-for loops.

unsigned arg_size() const

const APInt & getValue() const

Return the constant as an APInt value reference.

FunctionPass class - This class is used to implement most global optimizations.

void SetCurrentDebugLocation(DebugLoc L)

Set location information used by debugging information.

Value * CreateZExt(Value *V, Type *DestTy, const Twine &Name="", bool IsNonNeg=false)

Value * CreateAnd(Value *LHS, Value *RHS, const Twine &Name="")

Value * CreateTrunc(Value *V, Type *DestTy, const Twine &Name="", bool IsNUW=false, bool IsNSW=false)

void SetInsertPoint(BasicBlock *TheBB)

This specifies that created instructions should be appended to the end of the specified block.

Class to represent integer types.

static LLVM_ABI IntegerType * get(LLVMContext &C, unsigned NumBits)

This static method is the primary way of constructing an IntegerType.

unsigned getBitWidth() const

Get the number of bits in this IntegerType.

This is an important class for using LLVM in a threaded context.

Analysis pass that exposes the LoopInfo for a function.

LoopT * getLoopFor(const BlockT *BB) const

Return the inner most loop that BB lives in.

A set of analyses that are preserved following a run of a transformation pass.

static PreservedAnalyses all()

Construct a special preserved set that preserves all passes.

PreservedAnalyses & preserveSet()

Mark an analysis set as preserved.

PreservedAnalyses & preserve()

Mark an analysis as preserved.

A vector that has set insertion semantics.

size_type count(const_arg_type key) const

Count the number of elements of a given key in the SetVector.

bool empty() const

Determine if the SetVector is empty or not.

bool insert(const value_type &X)

Insert a new element into the SetVector.

value_type pop_back_val()

A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...

size_type count(ConstPtrType Ptr) const

count - Return 1 if the specified pointer is in the set, 0 otherwise.

std::pair< iterator, bool > insert(PtrType Ptr)

Inserts Ptr if and only if there is no element in the container equal to Ptr.

bool contains(ConstPtrType Ptr) const

SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.

Analysis pass providing the TargetTransformInfo.

EVT getValueType(const DataLayout &DL, Type *Ty, bool AllowUnknown=false) const

Return the EVT corresponding to this LLVM type.

virtual bool isSExtCheaperThanZExt(EVT FromTy, EVT ToTy) const

Return true if sign-extension from FromTy to ToTy is cheaper than zero-extension.

virtual EVT getTypeToTransformTo(LLVMContext &Context, EVT VT) const

For types supported by the target, this is an identity function.

bool isTypeLegal(EVT VT) const

Return true if the target has native support for the specified value type.

virtual bool isLegalAddImmediate(int64_t) const

Return true if the specified immediate is legal add immediate, that is the target has add instruction...

LegalizeTypeAction getTypeAction(LLVMContext &Context, EVT VT) const

Return how we should legalize values of this type, either it is already legal (return 'Legal') or we ...

virtual const TargetSubtargetInfo * getSubtargetImpl(const Function &) const

Virtual method implemented by subclasses that returns a reference to that target's TargetSubtargetInf...

virtual const TargetLowering * getTargetLowering() const

LLVM_ABI TypeSize getRegisterBitWidth(RegisterKind K) const

bool isPointerTy() const

True if this is an instance of PointerType.

LLVM_ABI TypeSize getPrimitiveSizeInBits() const LLVM_READONLY

Return the basic size of this type if it is a primitive type.

LLVM_ABI unsigned getScalarSizeInBits() const LLVM_READONLY

If this is a vector type, return the getPrimitiveSizeInBits value for the element type.

bool isVoidTy() const

Return true if this is 'void'.

LLVM Value Representation.

Type * getType() const

All values are typed, get the type of this value.

iterator_range< use_iterator > uses()

constexpr ScalarTy getFixedValue() const

self_iterator getIterator()

#define llvm_unreachable(msg)

Marks that the current location is not supposed to be reachable.

constexpr std::underlying_type_t< E > Mask()

Get a bitmask with 1s in all places up to the high-order bit of E's largest value.

unsigned ID

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

@ C

The default llvm calling convention, compatible with C.

@ BasicBlock

Various leaf nodes.

initializer< Ty > init(const Ty &Val)

@ Switch

The "resume-switch" lowering, where there are separate resume and destroy functions that are shared b...

PointerTypeMap run(const Module &M)

Compute the PointerTypeMap for the module M.

@ User

could "use" a pointer

NodeAddr< PhiNode * > Phi

friend class Instruction

Iterator for Instructions in a `BasicBlock.

This is an optimization pass for GlobalISel generic memory operations.

FunctionAddr VTableAddr Value

LLVM_ABI bool isLegalToPromote(const CallBase &CB, Function *Callee, const char **FailureReason=nullptr)

Return true if the given indirect call site can be made to call Callee.

LLVM_ABI FunctionPass * createTypePromotionLegacyPass()

Create IR Type Promotion pass.

Definition TypePromotion.cpp:1037

decltype(auto) dyn_cast(const From &Val)

dyn_cast - Return the argument parameter cast to the specified type.

LLVM_ABI raw_ostream & dbgs()

dbgs() - This returns a reference to a raw_ostream for debugging messages.

bool isa(const From &Val)

isa - Return true if the parameter to the template is an instance of one of the template type argu...

IRBuilder(LLVMContext &, FolderTy, InserterTy, MDNode *, ArrayRef< OperandBundleDef >) -> IRBuilder< FolderTy, InserterTy >

DWARFExpression::Operation Op

decltype(auto) cast(const From &Val)

cast - Return the argument parameter cast to the specified type.

LLVMAttributeRef wrap(Attribute Attr)

AnalysisManager< Function > FunctionAnalysisManager

Convenience typedef for the Function analysis manager.

bool isSimple() const

Test if the given EVT is simple (as opposed to being extended).

MVT getSimpleVT() const

Return the SimpleValueType held in the specified simple EVT.

uint64_t getFixedSizeInBits() const

Return the size of the specified fixed width value type in bits.