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

1

2

3

4

5

6

7

8

9

10

11

12

13

14#ifndef LLVM_CODEGEN_REGISTERBANKINFO_H

15#define LLVM_CODEGEN_REGISTERBANKINFO_H

16

25#include

26#include <initializer_list>

27#include

28

29namespace llvm {

30

38

39

41public:

42

43

44

45

46

47

48

50

51

52

54

55

56

57

59

60

62

64

65

69

70

71

73

74

75 void dump() const;

76

77

79

80

81

82

83

84

85

86

88 };

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

145

147

149

150

152

153

154

156

157

158

159

163

164

167

168

169

171

172

174

175

176

177

178

179

181

182

183 void dump() const;

184

185

187 };

188

189

190

192

193

194

196

197

198 unsigned Cost = 0;

199

200

201 const ValueMapping *OperandsMapping = nullptr;

202

203

204 unsigned NumOperands = 0;

205

206 const ValueMapping &getOperandMapping(unsigned i) {

208 return OperandsMapping[i];

209 }

210

211 public:

212

213

214

215

216

217

220 unsigned NumOperands)

221 : ID(ID), Cost(Cost), OperandsMapping(OperandsMapping),

222 NumOperands(NumOperands) {}

223

224

225

227

228

229 unsigned getCost() const { return Cost; }

230

231

232 unsigned getID() const { return ID; }

233

234

236

237

238

239

243 return ValMapping;

244 }

245

246

247

248

250 OperandsMapping = OpdsMapping;

251 }

252

253

254

258

259

260

261

262

263

264

266

267

268 void dump() const;

269

270

272 };

273

274

275

276

278

279

280

282

283

284

286

287

289

290

292

293

295

296

298

299

300

301 static const int DontKnowIdx;

302

303

304

305

306

307

308

310 getVRegsMem(unsigned OpIdx);

311

312

313

314

316 getNewVRegsEnd(unsigned StartIdx, unsigned NumVal) const;

318 unsigned NumVal);

319

320 public:

321

322

323

326

327

328

329

331

332

334

335

337

338

339

340

341

342

343

344

345

346

347

348

349

350

352

353

354

355

356

357

358

359

360

361

362

364

365

366

367

368

369

370

371

372

373

374

375

376

378 getVRegs(unsigned OpIdx, bool ForDebug = false) const;

379

380

381 void dump() const;

382

383

385 };

386

387protected:

388

390

391

393

394

396

397

399

400

401

404

405

406

409

410

411

414

415

416

419

420

421

423

424

425

428

429

430

431

432

433

434

438

439

444

445

446

449

450

451

452

453

454

455

456

457

458

459

460

461

462

463

464

465

466

468

469

470

473

474

475

476

477

478

481

482

483 const ValueMapping &getValueMapping(const PartialMapping *BreakDown,

484 unsigned NumBreakDowns) const;

485

486

487

488

489

490

491

492

493

494

495

496

497

498

499

500 template

501 const ValueMapping *getOperandsMapping(Iterator Begin, Iterator End) const;

502

503

504

505

506

507

510

511

512

513

514

515

517 std::initializer_list<const ValueMapping *> OpdsMapping) const;

518

519

520

521

522

523private:

524

526 getInstructionMappingImpl(bool IsInvalid, unsigned ID = InvalidMappingID,

527 unsigned Cost = 0,

528 const ValueMapping *OperandsMapping = nullptr,

529 unsigned NumOperands = 0) const;

530

531public:

532

536 unsigned NumOperands) const {

537 return getInstructionMappingImpl( false, ID, Cost,

538 OperandsMapping, NumOperands);

539 }

540

541

543 return getInstructionMappingImpl( true);

544 }

545

546

547

548

549

550

551

552

557

558

559

560

561

562

563

564

565

566

567

568

569

570

571

572

574

575

580

581public:

583

584

588

589

593

594

595

596

597

598

601

602

604

605

609

610

611

612

613

614

615

616

617

618

619

620

621

626

627

628

629

630

631

632

635

636

637

638

639 return &A != &B;

640 }

641

642

645 return copyCost(Dst, Src, Size) == std::numeric_limits::max();

646 }

647

648

649

650

651

652 virtual unsigned

654 const RegisterBank *CurBank = nullptr) const {

655 return std::numeric_limits::max();

656 }

657

658

659

660

661

662

663

664

668

669

670

671

673

674

675

676

678

679

680

681

682

683

684

685

686

687

688

689

690

691

692

693

694

695

696

697

698

699

700

703

704

705

708

709

710

711

712

713

714

715

716

717

718

719

720

721

722

723

724

726

727

728

729

730

731

732

733

734

745

746

747

748

749

750

751

754

755

756

757

758

759

760

762};

763

767 PartMapping.print(OS);

768 return OS;

769}

770

773 ValMapping.print(OS);

774 return OS;

775}

776

780 InstrMapping.print(OS);

781 return OS;

782}

783

786 OpdMapper.print(OS, false);

787 return OS;

788}

789

790

791

792hash_code hash_value(const RegisterBankInfo::PartialMapping &PartMapping);

793

794}

795

796#endif

unsigned const MachineRegisterInfo * MRI

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

const TargetInstrInfo & TII

static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")

static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")

This file defines the DenseMap class.

Implement a low-level type suitable for MachineInstr level instruction selection.

Register const TargetRegisterInfo * TRI

MachineInstr unsigned OpIdx

This file defines the SmallVector class.

Wrapper class representing physical registers. Should be passed by value.

Helper class to build MachineInstr.

Representation of each machine instruction.

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

Helper class that represents how the value of an instruction may be mapped and what is the related co...

Definition RegisterBankInfo.h:191

unsigned getNumOperands() const

Get the number of operands.

Definition RegisterBankInfo.h:235

unsigned getCost() const

Get the cost.

Definition RegisterBankInfo.h:229

unsigned getID() const

Get the ID.

Definition RegisterBankInfo.h:232

InstructionMapping()=default

Default constructor.

void setOperandsMapping(const ValueMapping *OpdsMapping)

Set the mapping for all the operands.

Definition RegisterBankInfo.h:249

void dump() const

Print this on dbgs() stream.

void print(raw_ostream &OS) const

Print this on OS;.

InstructionMapping(unsigned ID, unsigned Cost, const ValueMapping *OperandsMapping, unsigned NumOperands)

Constructor for the mapping of an instruction.

Definition RegisterBankInfo.h:218

const ValueMapping & getOperandMapping(unsigned i) const

Get the value mapping of the ith operand.

Definition RegisterBankInfo.h:240

bool isValid() const

Check whether this object is valid.

Definition RegisterBankInfo.h:255

Helper class used to get/create the virtual registers that will be used to replace the MachineOperand...

Definition RegisterBankInfo.h:281

const InstructionMapping & getInstrMapping() const

The final mapping of the instruction.

Definition RegisterBankInfo.h:333

void setVRegs(unsigned OpIdx, unsigned PartialMapIdx, Register NewVReg)

Set the virtual register of the PartialMapIdx-th partial mapping of the OpIdx-th operand to NewVReg.

void print(raw_ostream &OS, bool ForDebug=false) const

Print this operands mapper on OS stream.

MachineInstr & getMI() const

Definition RegisterBankInfo.h:330

void createVRegs(unsigned OpIdx)

Create as many new virtual registers as needed for the mapping of the OpIdx-th operand.

MachineRegisterInfo & getMRI() const

The MachineRegisterInfo we used to realize the mapping.

Definition RegisterBankInfo.h:336

OperandsMapper(MachineInstr &MI, const InstructionMapping &InstrMapping, MachineRegisterInfo &MRI)

Create an OperandsMapper that will hold the information to apply InstrMapping to MI.

void dump() const

Print this operands mapper on dbgs() stream.

iterator_range< SmallVectorImpl< Register >::const_iterator > getVRegs(unsigned OpIdx, bool ForDebug=false) const

Get all the virtual registers required to map the OpIdx-th operand of the instruction.

virtual bool isDivergentRegBank(const RegisterBank *RB) const

Returns true if the register bank is considered divergent.

Definition RegisterBankInfo.h:606

const PartialMapping & getPartialMapping(unsigned StartIdx, unsigned Length, const RegisterBank &RegBank) const

Get the uniquely generated PartialMapping for the given arguments.

void applyMapping(MachineIRBuilder &Builder, const OperandsMapper &OpdMapper) const

Apply OpdMapper.getInstrMapping() to OpdMapper.getMI().

Definition RegisterBankInfo.h:735

virtual InstructionMappings getInstrAlternativeMappings(const MachineInstr &MI) const

Get the alternative mappings for MI.

virtual ~RegisterBankInfo()=default

static const TargetRegisterClass * constrainGenericRegister(Register Reg, const TargetRegisterClass &RC, MachineRegisterInfo &MRI)

Constrain the (possibly generic) virtual register Reg to RC.

DenseMap< hash_code, std::unique_ptr< const InstructionMapping > > MapOfInstructionMappings

Keep dynamically allocated InstructionMapping in a separate map.

Definition RegisterBankInfo.h:418

const RegisterBank ** RegBanks

Hold the set of supported register banks.

Definition RegisterBankInfo.h:389

RegisterBankInfo()

This constructor is meaningless.

Definition RegisterBankInfo.h:435

DenseMap< hash_code, std::unique_ptr< const PartialMapping > > MapOfPartialMappings

Keep dynamically allocated PartialMapping in a separate map.

Definition RegisterBankInfo.h:403

virtual const InstructionMapping & getInstrMapping(const MachineInstr &MI) const

Get the mapping of the different operands of MI on the register bank.

virtual void applyMappingImpl(MachineIRBuilder &Builder, const OperandsMapper &OpdMapper) const

See applyMapping.

Definition RegisterBankInfo.h:576

unsigned NumRegBanks

Total number of register banks.

Definition RegisterBankInfo.h:392

const InstructionMapping & getInstructionMapping(unsigned ID, unsigned Cost, const ValueMapping *OperandsMapping, unsigned NumOperands) const

Method to get a uniquely generated InstructionMapping.

Definition RegisterBankInfo.h:534

static void applyDefaultMapping(const OperandsMapper &OpdMapper)

Helper method to apply something that is like the default mapping.

DenseMap< hash_code, std::unique_ptr< const ValueMapping > > MapOfValueMappings

Keep dynamically allocated ValueMapping in a separate map.

Definition RegisterBankInfo.h:408

const ValueMapping & getValueMapping(unsigned StartIdx, unsigned Length, const RegisterBank &RegBank) const

The most common ValueMapping consists of a single PartialMapping.

const InstructionMapping & getInvalidInstructionMapping() const

Method to get a uniquely generated invalid InstructionMapping.

Definition RegisterBankInfo.h:542

DenseMap< hash_code, std::unique_ptr< ValueMapping[]> > MapOfOperandsMappings

Keep dynamically allocated array of ValueMapping in a separate map.

Definition RegisterBankInfo.h:413

const RegisterBank & getRegBank(unsigned ID)

Get the register bank identified by ID.

Definition RegisterBankInfo.h:440

const unsigned * Sizes

Hold the sizes of the register banks for all HwModes.

Definition RegisterBankInfo.h:395

bool cannotCopy(const RegisterBank &Dst, const RegisterBank &Src, TypeSize Size) const

Definition RegisterBankInfo.h:643

unsigned getMaximumSize(unsigned RegBankID) const

Get the maximum size in bits that fits in the given register bank.

Definition RegisterBankInfo.h:590

unsigned getNumRegBanks() const

Get the total number of register banks.

Definition RegisterBankInfo.h:603

const RegisterBank * getRegBankFromConstraints(const MachineInstr &MI, unsigned OpIdx, const TargetInstrInfo &TII, const MachineRegisterInfo &MRI) const

Get the register bank for the OpIdx-th operand of MI form the encoding constraints,...

TypeSize getSizeInBits(Register Reg, const MachineRegisterInfo &MRI, const TargetRegisterInfo &TRI) const

Get the size in bits of Reg.

virtual const RegisterBank & getRegBankFromRegClass(const TargetRegisterClass &RC, LLT Ty) const

Get a register bank that covers RC.

Definition RegisterBankInfo.h:623

InstructionMappings getInstrPossibleMappings(const MachineInstr &MI) const

Get the possible mapping for MI.

const RegisterBank & getRegBank(unsigned ID) const

Get the register bank identified by ID.

Definition RegisterBankInfo.h:585

RegisterBankInfo(const RegisterBank **RegBanks, unsigned NumRegBanks, const unsigned *Sizes, unsigned HwMode)

Create a RegisterBankInfo that can accommodate up to NumRegBanks RegisterBank instances.

static const unsigned InvalidMappingID

Identifier used when the related instruction mapping instance is generated by the default constructor...

Definition RegisterBankInfo.h:677

const TargetRegisterClass * getMinimalPhysRegClass(MCRegister Reg, const TargetRegisterInfo &TRI) const

Get the MinimalPhysRegClass for Reg.

const ValueMapping * getOperandsMapping(Iterator Begin, Iterator End) const

Get the uniquely generated array of ValueMapping for the elements of between Begin and End.

DenseMap< MCRegister, const TargetRegisterClass * > PhysRegMinimalRCs

Getting the minimal register class of a physreg is expensive.

Definition RegisterBankInfo.h:422

static const unsigned DefaultMappingID

Identifier used when the related instruction mapping instance is generated by target independent code...

Definition RegisterBankInfo.h:672

unsigned HwMode

Current HwMode for the target.

Definition RegisterBankInfo.h:398

SmallVector< const InstructionMapping *, 4 > InstructionMappings

Convenient type to represent the alternatives for mapping an instruction.

Definition RegisterBankInfo.h:277

const ValueMapping * getOperandsMapping(std::initializer_list< const ValueMapping * > OpdsMapping) const

Get the uniquely generated array of ValueMapping for the given arguments.

virtual unsigned copyCost(const RegisterBank &A, const RegisterBank &B, TypeSize Size) const

Get the cost of a copy from B to A, or put differently, get the cost of A = COPY B.

Definition RegisterBankInfo.h:633

virtual unsigned getBreakDownCost(const ValueMapping &ValMapping, const RegisterBank *CurBank=nullptr) const

Get the cost of using ValMapping to decompose a register.

Definition RegisterBankInfo.h:653

const InstructionMapping & getInstrMappingImpl(const MachineInstr &MI) const

Try to get the mapping of MI.

This class implements the register bank concept.

Wrapper class representing virtual and physical registers.

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

typename SuperClass::const_iterator const_iterator

typename SuperClass::iterator iterator

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

TargetInstrInfo - Interface to description of machine instruction set.

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

A range adaptor for a pair of iterators.

This class implements an extremely fast bulk output stream that can only output to a stream.

This provides a very simple, boring adaptor for a begin and end iterator into a range type.

#define llvm_unreachable(msg)

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

unsigned ID

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

This is an optimization pass for GlobalISel generic memory operations.

hash_code hash_value(const FixedPointSemantics &Val)

raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)

Helper struct that represents how a value is partially mapped into a register.

Definition RegisterBankInfo.h:49

void print(raw_ostream &OS) const

Print this partial mapping on OS;.

constexpr PartialMapping(unsigned StartIdx, unsigned Length, const RegisterBank &RegBank)

Provide a shortcut for quickly building PartialMapping.

Definition RegisterBankInfo.h:66

unsigned StartIdx

Number of bits at which this partial mapping starts in the original value.

Definition RegisterBankInfo.h:53

unsigned getHighBitIdx() const

Definition RegisterBankInfo.h:72

void dump() const

Print this partial mapping on dbgs() stream.

const RegisterBank * RegBank

Register bank where the partial value lives.

Definition RegisterBankInfo.h:61

unsigned Length

Length of this mapping in bits.

Definition RegisterBankInfo.h:58

Helper struct that represents how a value is mapped through different register banks.

Definition RegisterBankInfo.h:146

constexpr ValueMapping(const PartialMapping *BreakDown, unsigned NumBreakDowns)

Initialize a ValueMapping with the given parameter.

Definition RegisterBankInfo.h:160

const PartialMapping * begin() const

Iterators through the PartialMappings.

Definition RegisterBankInfo.h:165

const PartialMapping * end() const

Definition RegisterBankInfo.h:166

void print(raw_ostream &OS) const

Print this on OS;.

bool partsAllUniform() const

bool isValid() const

Check if this ValueMapping is valid.

Definition RegisterBankInfo.h:173

unsigned NumBreakDowns

Number of partial mapping to break down this value.

Definition RegisterBankInfo.h:151

ValueMapping()

The default constructor creates an invalid (isValid() == false) instance.

Definition RegisterBankInfo.h:155

void dump() const

Print this on dbgs() stream.

const PartialMapping * BreakDown

How the value is broken down between the different register banks.

Definition RegisterBankInfo.h:148