Go to the documentation of this file.
14 #ifndef LLVM_LIB_TARGET_NVPTX_NVPTXASMPRINTER_H
15 #define LLVM_LIB_TARGET_NVPTX_NVPTXASMPRINTER_H
85 std::vector<unsigned char> buffer;
106 EmitGeneric = AP.EmitGeneric;
111 unsigned addBytes(
unsigned char *Ptr,
int Num,
int Bytes) {
114 for (
int i = 0;
i < Num; ++
i) {
115 buffer[curpos] = Ptr[
i];
118 for (
int i = Num;
i < Bytes; ++
i) {
125 unsigned addZeros(
int Num) {
127 for (
int i = 0;
i < Num; ++
i) {
135 symbolPosInBuffer.push_back(curpos);
136 Symbols.push_back(GVar);
137 SymbolsBeforeStripping.push_back(GVarBeforeStripping);
142 if (numSymbols == 0) {
144 for (
unsigned i = 0;
i <
size;
i++) {
147 O << (
unsigned int) buffer[
i];
151 unsigned int pos = 0;
152 unsigned int nSym = 0;
153 unsigned int nextSymbolPos = symbolPosInBuffer[nSym];
154 unsigned int nBytes = 4;
157 for (pos = 0; pos <
size; pos += nBytes) {
160 if (pos == nextSymbolPos) {
161 const Value *v = Symbols[nSym];
162 const Value *v0 = SymbolsBeforeStripping[nSym];
163 if (
const GlobalValue *GVar = dyn_cast<GlobalValue>(v)) {
166 bool IsNonGenericPointer =
false;
168 IsNonGenericPointer =
true;
170 if (EmitGeneric && !isa<Function>(v) && !IsNonGenericPointer) {
177 }
else if (
const ConstantExpr *CExpr = dyn_cast<ConstantExpr>(v0)) {
179 AP.lowerConstantForGV(cast<Constant>(CExpr),
false);
180 AP.printMCExpr(*Expr,
O);
184 if (nSym >= numSymbols)
185 nextSymbolPos =
size + 1;
187 nextSymbolPos = symbolPosInBuffer[nSym];
188 }
else if (nBytes == 4)
189 O << *(
unsigned int *)(&buffer[pos]);
191 O << *(
unsigned long long *)(&buffer[pos]);
197 friend class AggBuffer;
200 StringRef getPassName()
const override {
return "NVPTX Assembly Printer"; }
203 std::string CurrentFnName;
205 void emitStartOfAsmFile(
Module &
M)
override;
207 void emitFunctionEntryLabel()
override;
208 void emitFunctionBodyStart()
override;
209 void emitFunctionBodyEnd()
override;
216 unsigned encodeVirtualRegister(
unsigned Reg);
219 const char *Modifier =
nullptr);
224 void emitGlobals(
const Module &
M);
227 void emitVirtualRegister(
unsigned int vr,
raw_ostream &);
239 const MCExpr *lowerConstantForGV(
const Constant *CV,
bool ProcessingGeneric);
243 bool doInitialization(
Module &
M)
override;
244 bool doFinalization(
Module &
M)
override;
256 VRegRCMap VRegMapping;
259 std::map<const Function *, std::vector<const GlobalVariable *>> localDecls;
264 std::string getPTXFundamentalTypeStr(
Type *Ty,
bool =
true)
const;
267 void bufferLEByte(
const Constant *CPV,
int Bytes, AggBuffer *aggBuffer);
268 void bufferAggregateConstant(
const Constant *CV, AggBuffer *aggBuffer);
275 bool lowerImageHandleOperand(
const MachineInstr *
MI,
unsigned OpNo,
307 std::string getVirtualRegisterName(
unsigned)
const;
309 const MCSymbol *getFunctionFrameSymbol()
const override;
319 #endif // LLVM_LIB_TARGET_NVPTX_NVPTXASMPRINTER_H
This class represents an incoming formal argument to a Function.
This is an optimization pass for GlobalISel generic memory operations.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
void getAnalysisUsage(AnalysisUsage &AU) const override
Record analysis usage.
static void print(raw_ostream &Out, object::Archive::Kind Kind, T Val)
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
const MCAsmInfo * MAI
Target Asm Printer information.
Reg
All possible values of the reg field in the ModR/M byte.
unsigned getAddressSpace() const
Return the address space of the Pointer type.
The instances of the Type class are immutable: once they are created, they are never changed.
static bool printOperand(raw_ostream &OS, const SelectionDAG *G, const SDValue Value)
Instances of this class represent a single low-level machine instruction.
static void printMCExpr(const MCExpr *E, raw_ostream &OS)
Clang compiles this i1 i64 store i64 i64 store i64 i64 store i64 i64 store i64 align Which gets codegen d xmm0 movaps rbp movaps rbp movaps rbp movaps rbp rbp rbp rbp rbp It would be better to have movq s of instead of the movaps s LLVM produces ret int
Represent the analysis usage information of a pass.
MachineOperand class - Representation of each machine instruction operand.
This class implements an extremely fast bulk output stream that can only output to a stream.
ConstantFP - Floating Point Values [float, double].
This is an important base class in LLVM.
Representation of each machine instruction.
Class to represent pointers.
static void printMemOperand(raw_ostream &OS, const MachineMemOperand &MMO, const MachineFunction *MF, const Module *M, const MachineFrameInfo *MFI, const TargetInstrInfo *TII, LLVMContext &Ctx)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
MCSymbol * getSymbol(const GlobalValue *GV) const
Primary interface to the complete machine description for the target machine.
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
A Module instance is used to store all the information related to an LLVM module.
auto size(R &&Range, std::enable_if_t< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< decltype(Range.begin())>::iterator_category >::value, void > *=nullptr)
Get the size of a range.
StringRef - Represent a constant reference to a string, i.e.
void getAnalysisUsage(AnalysisUsage &AU) const override
Record analysis usage.
static MCOperand GetSymbolRef(const MachineOperand &MO, const MCSymbol *Symbol, HexagonAsmPrinter &Printer, bool MustExtend)
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Type * getType() const
All values are typed, get the type of this value.
#define LLVM_LIBRARY_VISIBILITY
LLVM_LIBRARY_VISIBILITY - If a class marked with this attribute is linked into a shared library,...
unsigned const MachineRegisterInfo * MRI
NVPTXAsmPrinter(TargetMachine &TM, std::unique_ptr< MCStreamer > Streamer)
A constant value that is initialized with an expression using other constant values.
void emitGlobalVariable(const GlobalVariable *GV) override
Emit the specified global variable to the .s file.
This class is intended to be used as a driving class for all asm writers.
TargetMachine & TM
Target machine description.
static void addSymbol(Object &Obj, const NewSymbolInfo &SymInfo, uint8_t DefaultVisibility)
const char LLVMTargetMachineRef TM
Instances of this class represent operands of the MCInst class.
AnalysisUsage & addRequired()
LLVM Value Representation.
Base class for the full range of assembler expressions which are needed for parsing.