94 #define DEPOTNAME "__local_depot" 104 if (
const User *U = dyn_cast<User>(V)) {
105 for (
unsigned i = 0, e = U->getNumOperands(); i != e; ++i) {
121 if (Visited.
count(GV))
125 if (!Visiting.
insert(GV).second)
146 lowerToMCInst(MI, Inst);
151 bool NVPTXAsmPrinter::lowerImageHandleOperand(
const MachineInstr *MI,
159 if (OpNo == 4 && MO.
isImm()) {
160 lowerImageHandleSymbol(MO.
getImm(), MCOp);
164 lowerImageHandleSymbol(MO.
getImm(), MCOp);
174 if (OpNo == VecSize && MO.
isImm()) {
175 lowerImageHandleSymbol(MO.
getImm(), MCOp);
182 if (OpNo == 0 && MO.
isImm()) {
183 lowerImageHandleSymbol(MO.
getImm(), MCOp);
190 if (OpNo == 1 && MO.
isImm()) {
191 lowerImageHandleSymbol(MO.
getImm(), MCOp);
201 void NVPTXAsmPrinter::lowerImageHandleSymbol(
unsigned Index,
MCOperand &MCOp) {
207 std::string *SymNamePtr =
215 if (MI->
getOpcode() == NVPTX::CALL_PROTOTYPE) {
228 if (lowerImageHandleOperand(MI, i, MCOp)) {
234 if (lowerOperand(MO, MCOp))
284 unsigned NVPTXAsmPrinter::encodeVirtualRegister(
unsigned Reg) {
289 unsigned RegNum = RegMap[
Reg];
294 if (RC == &NVPTX::Int1RegsRegClass) {
296 }
else if (RC == &NVPTX::Int16RegsRegClass) {
298 }
else if (RC == &NVPTX::Int32RegsRegClass) {
300 }
else if (RC == &NVPTX::Int64RegsRegClass) {
302 }
else if (RC == &NVPTX::Float32RegsRegClass) {
304 }
else if (RC == &NVPTX::Float64RegsRegClass) {
306 }
else if (RC == &NVPTX::Float16RegsRegClass) {
308 }
else if (RC == &NVPTX::Float16x2RegsRegClass) {
315 Ret |= (RegNum & 0x0FFFFFFF);
320 return Reg & 0x0FFFFFFF;
336 Type *Ty = F->getReturnType();
348 if (
auto *ITy = dyn_cast<IntegerType>(Ty)) {
349 size = ITy->getBitWidth();
360 O <<
".param .b" << size <<
" func_retval0";
361 }
else if (isa<PointerType>(Ty)) {
366 unsigned retAlignment = 0;
369 O <<
".param .align " << retAlignment <<
" .b8 func_retval0[" << totalsz
377 for (
unsigned i = 0, e = vtparts.
size(); i != e; ++i) {
379 EVT elemtype = vtparts[i];
381 elems = vtparts[i].getVectorNumElements();
382 elemtype = vtparts[i].getVectorElementType();
385 for (
unsigned j = 0, je = elems; j != je; ++j) {
389 O <<
".reg .b" << sz <<
" func_retval" << idx;
404 printReturnValStr(&F, O);
410 bool NVPTXAsmPrinter::isLoopHeaderOfNoUnroll(
439 if (isLoopHeaderOfNoUnroll(MBB))
443 void NVPTXAsmPrinter::EmitFunctionEntryLabel() {
447 if (!GlobalsEmitted) {
449 GlobalsEmitted =
true;
455 emitLinkageDirective(F, O);
460 printReturnValStr(*MF, O);
465 emitFunctionParamList(*MF, O);
468 emitKernelFunctionDirectives(*F, O);
475 setAndEmitFunctionVirtualRegisters(*MF);
489 void NVPTXAsmPrinter::EmitFunctionBodyStart() {
496 void NVPTXAsmPrinter::EmitFunctionBodyEnd() {
506 void NVPTXAsmPrinter::emitImplicitDef(
const MachineInstr *MI)
const {
519 void NVPTXAsmPrinter::emitKernelFunctionDirectives(
const Function &F,
524 unsigned reqntidx, reqntidy, reqntidz;
525 bool specified =
false;
540 O <<
".reqntid " << reqntidx <<
", " << reqntidy <<
", " << reqntidz
546 unsigned maxntidx, maxntidy, maxntidz;
562 O <<
".maxntid " << maxntidx <<
", " << maxntidy <<
", " << maxntidz
567 O <<
".minnctapersm " << mincta <<
"\n";
571 O <<
".maxnreg " << maxnreg <<
"\n";
582 assert(I != VRegMapping.
end() &&
"Bad register class");
586 assert(VI != RegMap.end() &&
"Bad virtual register");
587 unsigned MappedVR = VI->second;
595 void NVPTXAsmPrinter::emitVirtualRegister(
unsigned int vr,
600 void NVPTXAsmPrinter::printVecModifiedImmediate(
602 static const char vecelem[] = {
'0',
'1',
'2',
'3',
'0',
'1',
'2',
'3' };
603 int Imm = (int) MO.
getImm();
604 if (0 == strcmp(Modifier,
"vecelem"))
605 O <<
"_" << vecelem[Imm];
606 else if (0 == strcmp(Modifier,
"vecv4comm1")) {
607 if ((Imm < 0) || (Imm > 3))
609 }
else if (0 == strcmp(Modifier,
"vecv4comm2")) {
610 if ((Imm < 4) || (Imm > 7))
612 }
else if (0 == strcmp(Modifier,
"vecv4pos")) {
615 O <<
"_" << vecelem[Imm % 4];
616 }
else if (0 == strcmp(Modifier,
"vecv2comm1")) {
617 if ((Imm < 0) || (Imm > 1))
619 }
else if (0 == strcmp(Modifier,
"vecv2comm2")) {
620 if ((Imm < 2) || (Imm > 3))
622 }
else if (0 == strcmp(Modifier,
"vecv2pos")) {
625 O <<
"_" << vecelem[Imm % 2];
631 emitLinkageDirective(F, O);
636 printReturnValStr(F, O);
639 emitFunctionParamList(F, O);
648 return GV->getName() !=
"llvm.used";
652 if (
const Constant *C = dyn_cast<Constant>(U))
660 if (
const GlobalVariable *othergv = dyn_cast<GlobalVariable>(U)) {
661 if (othergv->getName() ==
"llvm.used")
665 if (
const Instruction *instr = dyn_cast<Instruction>(U)) {
666 if (instr->getParent() && instr->getParent()->getParent()) {
668 if (oneFunc && (curFunc != oneFunc))
711 if (
const Constant *cu = dyn_cast<Constant>(U)) {
714 }
else if (
const Instruction *
I = dyn_cast<Instruction>(U)) {
721 if (seenMap.
find(caller) != seenMap.
end())
734 emitDeclaration(F, O);
743 emitDeclaration(F, O);
747 if (
const Constant *
C = dyn_cast<Constant>(U)) {
752 emitDeclaration(F, O);
758 emitDeclaration(F, O);
763 if (!isa<Instruction>(U))
776 if (seenMap.
find(caller) != seenMap.
end()) {
777 emitDeclaration(F, O);
786 if (!GV)
return true;
788 if (!InitList)
return true;
805 "Module has a nontrivial global ctor, which NVPTX does not support.");
810 "Module has a nontrivial global dtor, which NVPTX does not support.");
821 emitHeader(M, OS1, *STI);
826 OutStreamer->AddComment(
"Start of file scope inline assembly");
830 OutStreamer->AddComment(
"End of file scope inline assembly");
834 GlobalsEmitted =
false;
839 void NVPTXAsmPrinter::emitGlobals(
const Module &M) {
843 emitDeclarations(M, OS2);
859 "Missed a global variable");
860 assert(GVVisiting.
size() == 0 &&
"Did not fully process a global variable");
863 for (
unsigned i = 0, e = Globals.
size(); i != e; ++i)
864 printModuleLevelGV(Globals[i], OS2);
874 O <<
"// Generated by LLVM NVPTX Back-End\n";
879 O <<
".version " << (PTXVersion / 10) <<
"." << (PTXVersion % 10) <<
"\n";
886 O <<
", texmode_independent";
888 bool HasFullDebugInfo =
false;
890 switch(
CU->getEmissionKind()) {
896 HasFullDebugInfo =
true;
899 if (HasFullDebugInfo)
908 O <<
".address_size ";
923 if (!GlobalsEmitted) {
925 GlobalsEmitted =
true;
932 int i, n = global_list.size();
942 while (!global_list.empty())
943 global_list.
remove(global_list.begin());
949 for (i = 0; i < n; i++)
950 global_list.
insert(global_list.end(), gv_array[i]);
962 ->outputDwarfFileDirectives();
989 void NVPTXAsmPrinter::emitLinkageDirective(
const GlobalValue *V,
991 if (static_cast<NVPTXTargetMachine &>(
TM).getDrvInterface() ==
NVPTX::CUDA) {
993 if (isa<GlobalVariable>(V)) {
1007 msg.append(
"Error: ");
1008 msg.append(
"Symbol ");
1011 msg.append(
"has unsupported appending linkage type");
1020 void NVPTXAsmPrinter::printModuleLevelGV(
const GlobalVariable *GVar,
1022 bool processDemoted) {
1065 emitPTXGlobalVariable(GVar, O);
1073 const Constant *Initializer =
nullptr;
1087 O <<
"addr_mode_" << i <<
" = ";
1093 O <<
"clamp_to_border";
1096 O <<
"clamp_to_edge";
1107 O <<
"filter_mode = ";
1122 O <<
", force_unnormalized_coords = 1";
1132 if (strncmp(GVar->
getName().
data(),
"unrollpragma", 12) == 0)
1136 if (strncmp(GVar->
getName().
data(),
"filename", 8) == 0)
1142 const Function *demotedFunc =
nullptr;
1144 O <<
"// " << GVar->
getName() <<
" has been demoted\n";
1145 if (localDecls.find(demotedFunc) != localDecls.end())
1146 localDecls[demotedFunc].push_back(GVar);
1148 std::vector<const GlobalVariable *> temp;
1149 temp.push_back(GVar);
1150 localDecls[demotedFunc] = temp;
1159 O <<
" .attribute(.managed)";
1174 O << getPTXFundamentalTypeStr(ETy,
false);
1185 if (!Initializer->
isNullValue() && !isa<UndefValue>(Initializer)) {
1187 printScalarConstant(Initializer, O);
1196 "' is not allowed in addrspace(" +
1202 unsigned int ElementSize = 0;
1220 if (!isa<UndefValue>(Initializer) && !Initializer->
isNullValue()) {
1221 AggBuffer aggBuffer(ElementSize, O, *
this);
1222 bufferAggregateConstant(Initializer, &aggBuffer);
1223 if (aggBuffer.numSymbols) {
1224 if (static_cast<const NVPTXTargetMachine &>(
TM).
is64Bit()) {
1228 O << ElementSize / 8;
1233 O << ElementSize / 4;
1273 if (localDecls.find(f) == localDecls.end())
1276 std::vector<const GlobalVariable *> &gvars = localDecls[f];
1278 for (
unsigned i = 0, e = gvars.size(); i != e; ++i) {
1279 O <<
"\t// demoted variable\n\t";
1280 printModuleLevelGV(gvars[i], O,
true);
1284 void NVPTXAsmPrinter::emitPTXAddressSpace(
unsigned int AddressSpace,
1307 NVPTXAsmPrinter::getPTXFundamentalTypeStr(
Type *Ty,
bool useB4PTR)
const {
1313 unsigned NumBits = cast<IntegerType>(Ty)->
getBitWidth();
1316 else if (NumBits <= 64) {
1317 std::string
name =
"u";
1318 return name +
utostr(NumBits);
1333 if (static_cast<const NVPTXTargetMachine &>(
TM).
is64Bit())
1347 void NVPTXAsmPrinter::emitPTXGlobalVariable(
const GlobalVariable *GVar,
1371 O << getPTXFundamentalTypeStr(ETy);
1377 int64_t ElementSize = 0;
1411 unsigned int alignStruct = 1;
1414 for (
unsigned i = 0, e = STy->getNumElements(); i != e; i++) {
1415 Type *ETy = STy->getElementType(i);
1417 if (align > alignStruct)
1418 alignStruct = align;
1432 O <<
"_param_" << paramIndex;
1441 unsigned paramIndex = 0;
1448 if (F->arg_empty()) {
1455 for (I = F->arg_begin(), E = F->arg_end(); I !=
E; ++
I, paramIndex++) {
1467 std::string sname = I->
getName();
1469 if (hasImageHandles)
1470 O <<
"\t.param .u64 .ptr .surfref ";
1472 O <<
"\t.param .surfref ";
1474 O <<
"_param_" << paramIndex;
1477 if (hasImageHandles)
1478 O <<
"\t.param .u64 .ptr .texref ";
1480 O <<
"\t.param .texref ";
1482 O <<
"_param_" << paramIndex;
1485 if (hasImageHandles)
1486 O <<
"\t.param .u64 .ptr .samplerref ";
1488 O <<
"\t.param .samplerref ";
1490 O <<
"_param_" << paramIndex;
1506 O <<
"\t.param .align " << align <<
" .b8 ";
1507 printParamName(I, paramIndex, O);
1508 O <<
"[" << sz <<
"]";
1519 if (static_cast<NVPTXTargetMachine &>(
TM).getDrvInterface() !=
1521 Type *ETy = PTy->getElementType();
1522 int addrSpace = PTy->getAddressSpace();
1523 switch (addrSpace) {
1528 O <<
".ptr .const ";
1531 O <<
".ptr .shared ";
1534 O <<
".ptr .global ";
1539 printParamName(I, paramIndex, O);
1549 O << getPTXFundamentalTypeStr(Ty);
1551 printParamName(I, paramIndex, O);
1557 if (isa<IntegerType>(Ty)) {
1561 }
else if (isa<PointerType>(Ty))
1571 O <<
"\t.param .b" << sz <<
" ";
1573 O <<
"\t.reg .b" << sz <<
" ";
1574 printParamName(I, paramIndex, O);
1580 assert(PTy &&
"Param with byval attribute should be a pointer type");
1581 Type *ETy = PTy->getElementType();
1583 if (isABI || isKernelFunc) {
1601 if (!isKernelFunc && align < 4)
1604 O <<
"\t.param .align " << align <<
" .b8 ";
1605 printParamName(I, paramIndex, O);
1606 O <<
"[" << sz <<
"]";
1615 for (
unsigned i = 0, e = vtparts.
size(); i != e; ++i) {
1617 EVT elemtype = vtparts[i];
1619 elems = vtparts[i].getVectorNumElements();
1620 elemtype = vtparts[i].getVectorElementType();
1623 for (
unsigned j = 0, je = elems; j != je; ++j) {
1627 O <<
"\t.reg .b" << sz <<
" ";
1628 printParamName(I, paramIndex, O);
1644 void NVPTXAsmPrinter::emitFunctionParamList(
const MachineFunction &MF,
1647 emitFunctionParamList(&F, O);
1650 void NVPTXAsmPrinter::setAndEmitFunctionVirtualRegisters(
1667 O <<
"\t.reg .b64 \t%SP;\n";
1668 O <<
"\t.reg .b64 \t%SPL;\n";
1670 O <<
"\t.reg .b32 \t%SP;\n";
1671 O <<
"\t.reg .b32 \t%SPL;\n";
1679 unsigned int numVRs =
MRI->getNumVirtRegs();
1680 for (
unsigned i = 0; i < numVRs; i++) {
1684 int n = regmap.
size();
1685 regmap.
insert(std::make_pair(vr, n + 1));
1705 int n = regmap.
size();
1709 O <<
"\t.reg " << rcname <<
" \t" << rcStr <<
"<" << (n+1)
1720 unsigned int numHex;
1739 if (
const ConstantInt *CI = dyn_cast<ConstantInt>(CPV)) {
1740 O << CI->getValue();
1743 if (
const ConstantFP *CFP = dyn_cast<ConstantFP>(CPV)) {
1744 printFPConstant(CFP, O);
1747 if (isa<ConstantPointerNull>(CPV)) {
1751 if (
const GlobalValue *GVar = dyn_cast<GlobalValue>(CPV)) {
1752 bool IsNonGenericPointer =
false;
1754 IsNonGenericPointer =
true;
1756 if (EmitGeneric && !isa<Function>(CPV) && !IsNonGenericPointer) {
1765 if (
const ConstantExpr *Cexpr = dyn_cast<ConstantExpr>(CPV)) {
1768 bool IsNonGenericPointer =
false;
1770 IsNonGenericPointer =
true;
1772 if (
const GlobalValue *GVar = dyn_cast<GlobalValue>(v)) {
1773 if (EmitGeneric && !isa<Function>(v) && !IsNonGenericPointer) {
1792 int64_t vp = (int64_t)val;
1793 for (
unsigned i = 0; i <
sizeof(
T); ++i) {
1794 p[i] = (
unsigned char)vp;
1799 int32_t *vp = (int32_t *)&val;
1800 for (
unsigned i = 0; i <
sizeof(int32_t); ++i) {
1801 p[i] = (
unsigned char)*vp;
1806 int64_t *vp = (int64_t *)&val;
1807 for (
unsigned i = 0; i <
sizeof(int64_t); ++i) {
1808 p[i] = (
unsigned char)*vp;
1813 void NVPTXAsmPrinter::bufferLEByte(
const Constant *CPV,
int Bytes,
1821 aggBuffer->addZeros(s);
1825 unsigned char ptr[8];
1831 unsigned char c = (
unsigned char)cast<ConstantInt>(CPV)->getZExtValue();
1832 ConvertIntToBytes<>(ptr, c);
1833 aggBuffer->addBytes(ptr, 1, Bytes);
1835 short int16 = (short)cast<ConstantInt>(CPV)->getZExtValue();
1836 ConvertIntToBytes<>(ptr, int16);
1837 aggBuffer->addBytes(ptr, 2, Bytes);
1839 if (
const ConstantInt *constInt = dyn_cast<ConstantInt>(CPV)) {
1840 int int32 = (int)(constInt->getZExtValue());
1841 ConvertIntToBytes<>(ptr, int32);
1842 aggBuffer->addBytes(ptr, 4, Bytes);
1844 }
else if (
const auto *Cexpr = dyn_cast<ConstantExpr>(CPV)) {
1845 if (
const auto *constInt = dyn_cast_or_null<ConstantInt>(
1847 int int32 = (int)(constInt->getZExtValue());
1848 ConvertIntToBytes<>(ptr, int32);
1849 aggBuffer->addBytes(ptr, 4, Bytes);
1852 if (Cexpr->getOpcode() == Instruction::PtrToInt) {
1854 aggBuffer->addSymbol(v, Cexpr->getOperand(0));
1855 aggBuffer->addZeros(4);
1861 if (
const ConstantInt *constInt = dyn_cast<ConstantInt>(CPV)) {
1862 long long int64 = (
long long)(constInt->getZExtValue());
1863 ConvertIntToBytes<>(ptr, int64);
1864 aggBuffer->addBytes(ptr, 8, Bytes);
1866 }
else if (
const ConstantExpr *Cexpr = dyn_cast<ConstantExpr>(CPV)) {
1867 if (
const auto *constInt = dyn_cast_or_null<ConstantInt>(
1869 long long int64 = (
long long)(constInt->getZExtValue());
1870 ConvertIntToBytes<>(ptr, int64);
1871 aggBuffer->addBytes(ptr, 8, Bytes);
1874 if (Cexpr->getOpcode() == Instruction::PtrToInt) {
1876 aggBuffer->addSymbol(v, Cexpr->getOperand(0));
1877 aggBuffer->addZeros(8);
1894 ConvertIntToBytes<>(ptr, float16);
1895 aggBuffer->addBytes(ptr, 2, Bytes);
1899 aggBuffer->addBytes(ptr, 4, Bytes);
1903 aggBuffer->addBytes(ptr, 8, Bytes);
1910 if (
const GlobalValue *GVar = dyn_cast<GlobalValue>(CPV)) {
1911 aggBuffer->addSymbol(GVar, GVar);
1912 }
else if (
const ConstantExpr *Cexpr = dyn_cast<ConstantExpr>(CPV)) {
1914 aggBuffer->addSymbol(v, Cexpr);
1917 aggBuffer->addZeros(s);
1924 if (isa<ConstantAggregate>(CPV) || isa<ConstantDataSequential>(CPV)) {
1926 bufferAggregateConstant(CPV, aggBuffer);
1927 if (Bytes > ElementSize)
1928 aggBuffer->addZeros(Bytes - ElementSize);
1929 }
else if (isa<ConstantAggregateZero>(CPV))
1930 aggBuffer->addZeros(Bytes);
1941 void NVPTXAsmPrinter::bufferAggregateConstant(
const Constant *CPV,
1947 if (
const ConstantInt *CI = dyn_cast<ConstantInt>(CPV)) {
1948 APInt Val = CI->getValue();
1951 aggBuffer->addBytes(&Byte, 1, 1);
1958 if (isa<ConstantArray>(CPV) || isa<ConstantVector>(CPV)) {
1961 bufferLEByte(cast<Constant>(CPV->
getOperand(i)), 0, aggBuffer);
1966 dyn_cast<ConstantDataSequential>(CPV)) {
1967 if (CDS->getNumElements())
1968 for (
unsigned i = 0; i < CDS->getNumElements(); ++i)
1969 bufferLEByte(cast<Constant>(CDS->getElementAsConstant(i)), 0,
1974 if (isa<ConstantStruct>(CPV)) {
1985 bufferLEByte(cast<Constant>(CPV->
getOperand(i)), Bytes, aggBuffer);
1998 NVPTXAsmPrinter::lowerConstantForGV(
const Constant *CV,
bool ProcessingGeneric) {
2004 if (
const ConstantInt *CI = dyn_cast<ConstantInt>(CV))
2007 if (
const GlobalValue *GV = dyn_cast<GlobalValue>(CV)) {
2010 if (ProcessingGeneric) {
2029 return lowerConstantForGV(
C, ProcessingGeneric);
2035 OS <<
"Unsupported expression in static initializer: ";
2041 case Instruction::AddrSpaceCast: {
2045 return lowerConstantForGV(cast<const Constant>(CE->
getOperand(0)),
true);
2049 OS <<
"Unsupported expression in static initializer: ";
2055 case Instruction::GetElementPtr: {
2060 cast<GEPOperator>(CE)->accumulateConstantOffset(DL, OffsetAI);
2072 case Instruction::Trunc:
2078 case Instruction::BitCast:
2079 return lowerConstantForGV(CE->
getOperand(0), ProcessingGeneric);
2081 case Instruction::IntToPtr: {
2089 return lowerConstantForGV(Op, ProcessingGeneric);
2092 case Instruction::PtrToInt: {
2100 const MCExpr *OpExpr = lowerConstantForGV(Op, ProcessingGeneric);
2118 const MCExpr *LHS = lowerConstantForGV(CE->
getOperand(0), ProcessingGeneric);
2119 const MCExpr *RHS = lowerConstantForGV(CE->
getOperand(1), ProcessingGeneric);
2132 return cast<MCTargetExpr>(&Expr)->printImpl(OS,
MAI);
2134 OS << cast<MCConstantExpr>(Expr).getValue();
2160 if (isa<MCConstantExpr>(BE.
getLHS()) || isa<MCSymbolRefExpr>(BE.
getLHS()) ||
2161 isa<NVPTXGenericMCSymbolRefExpr>(BE.
getLHS())) {
2173 if (RHSC->getValue() < 0) {
2174 OS << RHSC->getValue();
2185 if (isa<MCConstantExpr>(BE.
getRHS()) || isa<MCSymbolRefExpr>(BE.
getRHS())) {
2201 bool NVPTXAsmPrinter::PrintAsmOperand(
const MachineInstr *MI,
unsigned OpNo,
2202 unsigned AsmVariant,
2204 if (ExtraCode && ExtraCode[0]) {
2205 if (ExtraCode[1] != 0)
2208 switch (ExtraCode[0]) {
2222 bool NVPTXAsmPrinter::PrintAsmMemoryOperand(
2223 const MachineInstr *MI,
unsigned OpNo,
unsigned AsmVariant,
2225 if (ExtraCode && ExtraCode[0])
2241 if (MO.
getReg() == NVPTX::VRDepot)
2246 emitVirtualRegister(MO.
getReg(),
O);
2253 else if (strstr(Modifier,
"vec") == Modifier)
2254 printVecModifiedImmediate(MO, Modifier, O);
2257 "Don't know how to handle modifier on immediate operand");
2281 if (Modifier && strcmp(Modifier,
"add") == 0) {
static unsigned getBitWidth(Type *Ty, const DataLayout &DL)
Returns the bitwidth of the given scalar or pointer type.
StringRef getSection() const
Get the custom section of this global if it has one.
unsigned getAlignment() const
unsigned getPTXVersion() const
A parsed version of the target data layout string in and methods for querying it. ...
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
static Type * getDoubleTy(LLVMContext &C)
unsigned getOpcode() const
Return the opcode at the root of this constant expression.
uint64_t getZExtValue() const
Get zero extended value.
This class represents an incoming formal argument to a Function.
MachineBasicBlock * getMBB() const
std::unique_ptr< MCStreamer > OutStreamer
This is the MCStreamer object for the file we are generating.
bool hasDebugInfo() const
Returns true if valid debug info is present.
MCSymbol * GetExternalSymbolSymbol(StringRef Sym) const
Return the MCSymbol for the specified ExternalSymbol.
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx)
bool getAlign(const Function &F, unsigned index, unsigned &align)
bool hasPrivateLinkage() const
const MachineFunction * getMF() const
Return the function that contains the basic block that this instruction belongs to.
const Constant * getInitializer() const
getInitializer - Return the initializer for this global variable.
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
This class represents lattice values for constants.
bool getMaxNReg(const Function &F, unsigned &x)
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
static unsigned index2VirtReg(unsigned Index)
Convert a 0-based index to a virtual register number.
A Module instance is used to store all the information related to an LLVM module. ...
unsigned getPointerPrefAlignment(unsigned AS=0) const
Return target's alignment for stack-based pointers FIXME: The defaults need to be removed once all of...
2: 32-bit floating point type
bool doFinalization(Module &M) override
Shut down the asmprinter.
MCContext & OutContext
This is the context for the output file that we are streaming.
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
static MCOperand createExpr(const MCExpr *Val)
Implements a dense probed hash-table based set.
const StructLayout * getStructLayout(StructType *Ty) const
Returns a StructLayout object, indicating the alignment of the struct, its size, and the offsets of i...
void push_back(const T &Elt)
Describe properties that are true of each instruction in the target description file.
unsigned getReg() const
getReg - Returns the register number.
static bool isVirtualRegister(unsigned Reg)
Return true if the specified register number is in the virtual register namespace.
bool isTexture(const Value &val)
bool hasAvailableExternallyLinkage() const
Opcode getOpcode() const
Get the kind of this unary expression.
float convertToFloat() const
const GlobalVariable * getNamedGlobal(StringRef Name) const
Return the global variable in the module with the specified name, of arbitrary type.
const MCExpr * getLHS() const
Get the left-hand side expression of the binary operator.
LLVMContext & getContext() const
All values hold a context through their type.
bool erase(const ValueT &V)
A raw_ostream that writes to an SmallVector or SmallString.
MachineBasicBlock reference.
unsigned const TargetRegisterInfo * TRI
static const MCBinaryExpr * createAnd(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
bool isInteger() const
Return true if this is an integer or a vector integer type.
MachineFunction * MF
The current machine function.
1: 16-bit floating point type
const GlobalListType & getGlobalList() const
Get the Module's list of global variables (constant).
static IntegerType * getInt64Ty(LLVMContext &C)
bool isVectorTy() const
True if this is an instance of VectorType.
static IntegerType * getInt16Ty(LLVMContext &C)
bool isImm() const
isImm - Tests if this is a MO_Immediate operand.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
const TargetRegisterClass * getRegClass(unsigned i) const
Returns the register class associated with the enumeration value.
static const NVPTXFloatMCExpr * createConstantFPSingle(const APFloat &Flt, MCContext &Ctx)
bool hasImageHandles() const
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
static GCMetadataPrinterRegistry::Add< OcamlGCMetadataPrinter > Y("ocaml", "ocaml 3.10-compatible collector")
static void DiscoverDependentGlobals(const Value *V, DenseSet< const GlobalVariable *> &Globals)
DiscoverDependentGlobals - Return a set of GlobalVariables on which V depends.
const MCSymbol * getFunctionFrameSymbol() const override
Return symbol for the function pseudo stack if the stack frame is not a register based.
static Constant * getIntegerCast(Constant *C, Type *Ty, bool isSigned)
Create a ZExt, Bitcast or Trunc for integer -> integer casts.
amdgpu Simplify well known AMD library false Value Value const Twine & Name
APInt getLoBits(unsigned numBits) const
Compute an APInt containing numBits lowbits from this APInt.
static MCOperand createReg(unsigned Reg)
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
static Type * getFloatTy(LLVMContext &C)
unsigned getPointerTypeSizeInBits(Type *) const
Layout pointer size, in bits, based on the type.
TypeID getTypeID() const
Return the type id for the type.
bool isFloatingPointTy() const
Return true if this is one of the six floating-point types.
static bool usedInOneFunc(const User *U, Function const *&oneFunc)
const ConstantFP * getFPImm() const
unsigned getNumOperands() const
Retuns the total number of operands.
Class to represent struct types.
void clearAnnotationCache(const Module *Mod)
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Base class for the full range of assembler expressions which are needed for parsing.
bool isIntegerTy() const
True if this is an instance of IntegerType.
Name of external global symbol.
This file contains the simple types necessary to represent the attributes associated with functions a...
Represent a reference to a symbol from inside an expression.
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted...
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
static const NVPTXFloatMCExpr * createConstantFPDouble(const APFloat &Flt, MCContext &Ctx)
const char * getSymbolName() const
void lshrInPlace(unsigned ShiftAmt)
Logical right-shift this APInt by ShiftAmt in place.
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...
bool hasCommonLinkage() const
Target & getTheNVPTXTarget64()
unsigned getNumRegClasses() const
bool getMaxNTIDz(const Function &F, unsigned &z)
unsigned getSizeInBits() const
Context object for machine code objects.
bool hasExternalLinkage() const
Constant * ConstantFoldConstant(const Constant *C, const DataLayout &DL, const TargetLibraryInfo *TLI=nullptr)
ConstantFoldConstant - Attempt to fold the constant using the specified DataLayout.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool startswith(StringRef Prefix) const
Check if this string starts with the given Prefix.
bool isNullValue() const
Return true if this is the value that would be returned by getNullValue.
A constant value that is initialized with an expression using other constant values.
Class to represent function types.
unsigned getSizeInBits() const
Return the size of the specified value type in bits.
int64_t getSExtValue() const
Get sign extended value.
bool isKernelFunction(const Function &F)
const MCInstrDesc & getDesc() const
Returns the target instruction descriptor of this MachineInstr.
Type * getType() const
All values are typed, get the type of this value.
bool isSurface(const Value &val)
bool runOnMachineFunction(MachineFunction &MF) override
Emit the specified function out to the OutStreamer.
opStatus convert(const fltSemantics &ToSemantics, roundingMode RM, bool *losesInfo)
ConstantDataSequential - A vector or array constant whose element type is a simple 1/2/4/8-byte integ...
const MCExpr * getRHS() const
Get the right-hand side expression of the binary operator.
Unary assembler expressions.
Class to represent array types.
bool getMaxNTIDx(const Function &F, unsigned &x)
std::string getTextureName(const Value &val)
ManagedStringPool * getManagedStrPool() const
bool isIntOrPtrTy() const
Return true if this is an integer type or a pointer type.
bool runOnMachineFunction(MachineFunction &F) override
Emit the specified function out to the OutStreamer.
AttributeList getAttributes() const
Return the attribute list for this Function.
RegisterAsmPrinter - Helper template for registering a target specific assembly printer, for use in the target machine initialization function.
static const fltSemantics & IEEEdouble() LLVM_READNONE
static const MCBinaryExpr * createAdd(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
bool hasLinkOnceLinkage() const
bool isSampler(const Value &val)
void ComputeValueVTs(const TargetLowering &TLI, const DataLayout &DL, Type *Ty, SmallVectorImpl< EVT > &ValueVTs, SmallVectorImpl< uint64_t > *Offsets=nullptr, uint64_t StartingOffset=0)
ComputeValueVTs - Given an LLVM IR type, compute a sequence of EVTs that represent all the individual...
const NVPTXSubtarget * getSubtargetImpl(const Function &) const override
Virtual method implemented by subclasses that returns a reference to that target's TargetSubtargetInf...
MachineModuleInfo * MMI
This is a pointer to the current MachineModuleInfo.
Value * getOperand(unsigned i) const
Instances of this class represent a single low-level machine instruction.
static const NVPTXGenericMCSymbolRefExpr * create(const MCSymbolRefExpr *SymExpr, MCContext &Ctx)
Class to represent pointers.
bool hasAppendingLinkage() const
iterator find(const_arg_type_t< KeyT > Val)
11: Arbitrary bit width integers
Target & getTheNVPTXTarget32()
IntegerType * getIntPtrType(LLVMContext &C, unsigned AddressSpace=0) const
Returns an integer type with size at least as big as that of a pointer in the given address space...
Address of a global value.
static bool isEmptyXXStructor(GlobalVariable *GV)
uint64_t getZExtValue() const
Return the constant as a 64-bit unsigned integer value after it has been zero extended as appropriate...
void print(raw_ostream &OS, const MCAsmInfo *MAI, bool InParens=false) const
unsigned const MachineRegisterInfo * MRI
MCSymbol * CurrentFnSym
The symbol for the current function.
MVT getPointerTy(const DataLayout &DL, uint32_t AS=0) const
Return the pointer type for the given address space, defaults to the pointer type from the data layou...
LLVM Basic Block Representation.
const MCAsmInfo * MAI
Target Asm Printer information.
The instances of the Type class are immutable: once they are created, they are never changed...
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
const char * getImageHandleSymbol(unsigned Idx) const
Returns the symbol name at the given index.
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This is an important base class in LLVM.
static bool is64Bit(const char *name)
This file contains the declarations for the subclasses of Constant, which represent the different fla...
bool isPointerTy() const
True if this is an instance of PointerType.
static MCOperand GetSymbolRef(const MachineOperand &MO, const MCSymbol *Symbol, HexagonAsmPrinter &Printer, bool MustExtend)
const GlobalValue * getGlobal() const
const NVPTXTargetLowering * getTargetLowering() const override
virtual bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo, unsigned AsmVariant, const char *ExtraCode, raw_ostream &OS)
Print the specified operand of MI, an INLINEASM instruction, using the specified assembler variant...
std::pair< iterator, bool > insert(const ValueT &V)
ConstantFP - Floating Point Values [float, double].
size_t alias_size() const
double convertToDouble() const
TargetMachine & TM
Target machine description.
std::string getTargetName() const
unsigned getPrefTypeAlignment(Type *Ty) const
Returns the preferred stack/global alignment for the specified type.
This file declares a class to represent arbitrary precision floating point values and provide a varie...
unsigned getMaxAlignment() const
Return the alignment in bytes that this function must be aligned to, which is greater than the defaul...
bool hasInternalLinkage() const
bool isHalfTy() const
Return true if this is 'half', a 16-bit IEEE fp type.
static const char * getRegisterName(unsigned RegNo)
This class describes a target machine that is implemented with the LLVM target-independent code gener...
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
unsigned getAddressSpace() const
Return the address space of the Pointer type.
NVPTX::DrvInterface getDrvInterface() const
const Value * stripPointerCasts() const
Strip off pointer casts, all-zero GEPs, and aliases.
Binary assembler expressions.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
pred_iterator pred_begin()
std::string getVirtualRegisterName(unsigned) const
void printAsOperand(raw_ostream &O, bool PrintType=true, const Module *M=nullptr) const
Print the name of this Value out to the specified raw_ostream.
std::string & str()
Flushes the stream contents to the target string and returns the string's reference.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
bool getMaxNTIDy(const Function &F, unsigned &y)
bool getReqNTIDx(const Function &F, unsigned &x)
bool hasWeakLinkage() const
const APFloat & getValueAPF() const
bool isImage(const Value &val)
bool getReqNTIDz(const Function &F, unsigned &z)
unsigned getFunctionNumber() const
Return a unique ID for the current function.
static Type * getHalfTy(LLVMContext &C)
static const fltSemantics & IEEEsingle() LLVM_READNONE
static void printMemOperand(raw_ostream &OS, const MachineMemOperand &MMO, const MachineFunction *MF, const Module *M, const MachineFrameInfo *MFI, const TargetInstrInfo *TII, LLVMContext &Ctx)
Iterator for intrusive lists based on ilist_node.
unsigned getNumOperands() const
bool hasParamAttribute(unsigned ArgNo, Attribute::AttrKind Kind) const
Equivalent to hasAttribute(ArgNo + FirstArgIndex, Kind).
void setOpcode(unsigned Op)
This is the shared class of boolean and integer constants.
auto size(R &&Range, typename std::enable_if< std::is_same< typename std::iterator_traits< decltype(Range.begin())>::iterator_category, std::random_access_iterator_tag >::value, void >::type *=nullptr) -> decltype(std::distance(Range.begin(), Range.end()))
Get the size of a range.
static void ConvertFloatToBytes(unsigned char *p, float val)
std::string * getManagedString(const char *S)
16: SIMD 'packed' format, or other vector type
static void printMCExpr(const MCExpr *E, raw_ostream &OS)
unsigned getScalarSizeInBits() const LLVM_READONLY
If this is a vector type, return the getPrimitiveSizeInBits value for the element type...
MCSymbol * getSymbol(const GlobalValue *GV) const
const MCSymbol & getSymbol() const
virtual const MCExpr * lowerConstant(const Constant *CV)
Lower the specified LLVM Constant to an MCExpr.
MachineOperand class - Representation of each machine instruction operand.
bool hasSection() const
Check if this global has a custom object file section.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Module.h This file contains the declarations for the Module class.
bool isVector(MCInstrInfo const &MCII, MCInst const &MCI)
unsigned getABITypeAlignment(Type *Ty) const
Returns the minimum ABI-required alignment for the specified type.
bool isImageReadWrite(const Value &val)
bool isAggregateType() const
Return true if the type is an aggregate type.
void EmitToStreamer(MCStreamer &S, const MCInst &Inst)
bool doInitialization(Module &M) override
Set up the AsmPrinter when we are working on a new module.
StringRef str()
Return a StringRef for the vector contents.
std::string getSurfaceName(const Value &val)
const char * getName(unsigned RegNo) const
static void VisitGlobalVariableForEmission(const GlobalVariable *GV, SmallVectorImpl< const GlobalVariable *> &Order, DenseSet< const GlobalVariable *> &Visited, DenseSet< const GlobalVariable *> &Visiting)
VisitGlobalVariableForEmission - Add GV to the list of GlobalVariable instances to be emitted...
std::string utostr(uint64_t X, bool isNeg=false)
Intrinsic::ID getIntrinsicID() const LLVM_READONLY
getIntrinsicID - This method returns the ID number of the specified function, or Intrinsic::not_intri...
const Function & getFunction() const
Return the LLVM function that this machine code represents.
std::string getSamplerName(const Value &val)
Class for arbitrary precision integers.
ConstantArray - Constant Array Declarations.
bool isManaged(const Value &val)
bool getReqNTIDy(const Function &F, unsigned &y)
iterator_range< user_iterator > users()
MDNode * GetUnrollMetadata(MDNode *LoopID, StringRef Name)
Given an llvm.loop loop id metadata node, returns the loop hint metadata node with the given name (fo...
uint64_t getTypeAllocSize(Type *Ty) const
Returns the offset in bytes between successive objects of the specified type, including alignment pad...
Representation of each machine instruction.
pointer remove(iterator &IT)
static bool isPhysicalRegister(unsigned Reg)
Return true if the specified register number is in the physical register namespace.
static bool printOperand(raw_ostream &OS, const SelectionDAG *G, const SDValue Value)
unsigned getParamAlignment(unsigned ArgNo) const
Return the alignment for the specified function parameter.
bool doInitialization(Module &M) override
Set up the AsmPrinter when we are working on a new module.
iterator insert(iterator where, pointer New)
const Function * getParent() const
std::string getNVPTXRegClassStr(TargetRegisterClass const *RC)
uint64_t getElementOffset(unsigned Idx) const
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
static IntegerType * getInt32Ty(LLVMContext &C)
MCSymbol * getOrCreateSymbol(const Twine &Name)
Lookup the symbol inside with the specified Name.
virtual void EmitBasicBlockStart(const MachineBasicBlock &MBB) const
Targets can override this to emit stuff at the start of a basic block.
static bool usedInGlobalVarDef(const Constant *C)
StringRef getName() const
Return a constant reference to the value's name.
const Function * getParent() const
Return the enclosing method, or null if none.
FormattedNumber format_hex_no_prefix(uint64_t N, unsigned Width, bool Upper=false)
format_hex_no_prefix - Output N as a fixed width hexadecimal.
MCSymbol * getSymbol() const
Return the MCSymbol for this basic block.
std::string getNVPTXRegClassName(TargetRegisterClass const *RC)
iterator_range< debug_compile_units_iterator > debug_compile_units() const
Return an iterator for all DICompileUnits listed in this Module's llvm.dbg.cu named metadata node and...
const BasicBlock * getBasicBlock() const
Return the LLVM basic block that this instance corresponded to originally.
virtual void print(raw_ostream &OS, const Module *M) const
print - Print out the internal state of the pass.
References to labels and assigned expressions.
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
Type * getValueType() const
size_type count(const_arg_type_t< ValueT > V) const
Return 1 if the specified key is in the set, 0 otherwise.
const LLVMTargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
static const NVPTXFloatMCExpr * createConstantFPHalf(const APFloat &Flt, MCContext &Ctx)
static bool canDemoteGlobalVar(const GlobalVariable *gv, Function const *&f)
const std::string & getModuleInlineAsm() const
Get any module-scope inline assembly blocks.
Opcode getOpcode() const
Get the kind of this binary expression.
bool isDeclaration() const
Return true if the primary definition of this global value is outside of the current translation unit...
3: 64-bit floating point type
Implments NVPTX-specific streamer.
bool hasFnAttribute(Attribute::AttrKind Kind) const
Equivalent to hasAttribute(AttributeList::FunctionIndex, Kind) but may be faster. ...
static unsigned int getOpenCLAlignment(const DataLayout &DL, Type *Ty)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static bool useFuncSeen(const Constant *C, DenseMap< const Function *, bool > &seenMap)
A raw_ostream that writes to an std::string.
const MCExpr * getSubExpr() const
Get the child of this unary expression.
bool isSingleValueType() const
Return true if the type is a valid type for a register in codegen.
unsigned getPrimitiveSizeInBits() const LLVM_READONLY
Return the basic size of this type if it is a primitive type.
Module * getParent()
Get the module that this global value is contained inside of...
LLVM Value Representation.
bool isLoopHeader(const MachineBasicBlock *BB) const
True if the block is a loop header node.
Floating-point immediate operand.
uint64_t getTypeStoreSize(Type *Ty) const
Returns the maximum number of bytes that may be overwritten by storing the specified type...
bool hasInitializer() const
Definitions have initializers, declarations don't.
MachineLoop * getLoopFor(const MachineBasicBlock *BB) const
Return the innermost loop that BB lives in.
unsigned int getSmVersion() const
This class implements an extremely fast bulk output stream that can only output to a stream...
uint64_t getTypeAllocSizeInBits(Type *Ty) const
Returns the offset in bits between successive objects of the specified type, including alignment padd...
const DataLayout & getDataLayout() const
Return information about data layout.
static void ConvertDoubleToBytes(unsigned char *p, double val)
iterator_range< global_iterator > globals()
void addOperand(const MCOperand &Op)
StringRef - Represent a constant reference to a string, i.e.
APInt bitcastToAPInt() const
bool getMinCTASm(const Function &F, unsigned &x)
Target specific expression.
static void ConvertIntToBytes(unsigned char *p, T val)
const STC & getSubtarget(const Function &F) const
This method returns a pointer to the specified type of TargetSubtargetInfo.
const MachineOperand & getOperand(unsigned i) const
Instances of this class represent operands of the MCInst class.
MachineOperandType getType() const
getType - Returns the MachineOperandType for this operand.
uint64_t getStackSize() const
Return the number of bytes that must be allocated to hold all of the fixed size frame objects...
static MCOperand createImm(int64_t Val)
static IntegerType * getInt8Ty(LLVMContext &C)
static const MCConstantExpr * create(int64_t Value, MCContext &Ctx)
bool isImageWriteOnly(const Value &val)
PointerType * getType() const
Global values are always pointers.
void LLVMInitializeNVPTXAsmPrinter()
bool doFinalization(Module &M) override
Shut down the asmprinter.
This file describes how to lower LLVM code to machine code.
const BasicBlock * getParent() const
const NVPTXRegisterInfo * getRegisterInfo() const override
void print(raw_ostream &OS, const MCAsmInfo *MAI) const
print - Print the value to the stream OS.