llvm.org GIT mirror llvm / 68226a4
PTX: Print .ptr kernel attributes if PTX version >= 2.2 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141508 91177308-0d34-0410-b5e6-96231b3b80d8 Justin Holewinski 8 years ago
4 changed file(s) with 49 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
1919 #include "PTXParamManager.h"
2020 #include "PTXRegisterInfo.h"
2121 #include "PTXTargetMachine.h"
22 #include "llvm/Argument.h"
2223 #include "llvm/DerivedTypes.h"
24 #include "llvm/Function.h"
2325 #include "llvm/Module.h"
2426 #include "llvm/ADT/SmallString.h"
2527 #include "llvm/ADT/StringExtras.h"
444446
445447 decl += " (";
446448
449 const Function *F = MF->getFunction();
450
447451 // Print parameters
448452 if (isKernel || ST.useParamSpaceForDeviceArgs()) {
449 for (PTXParamManager::param_iterator i = PM.arg_begin(), e = PM.arg_end(),
453 /*for (PTXParamManager::param_iterator i = PM.arg_begin(), e = PM.arg_end(),
450454 b = i; i != e; ++i) {
451455 if (i != b) {
452456 decl += ", ";
456460 decl += utostr(PM.getParamSize(*i));
457461 decl += " ";
458462 decl += PM.getParamName(*i);
463 }*/
464 int Counter = 1;
465 for (Function::const_arg_iterator i = F->arg_begin(), e = F->arg_end(),
466 b = i; i != e; ++i) {
467 if (i != b)
468 decl += ", ";
469 const Type *ArgType = (*i).getType();
470 decl += ".param .b";
471 if (ArgType->isPointerTy()) {
472 if (ST.is64Bit())
473 decl += "64";
474 else
475 decl += "32";
476 } else {
477 decl += utostr(ArgType->getPrimitiveSizeInBits());
478 }
479 if (ArgType->isPointerTy() && ST.emitPtrAttribute()) {
480 const PointerType *PtrType = dyn_cast(ArgType);
481 decl += " .ptr";
482 switch (PtrType->getAddressSpace()) {
483 default:
484 llvm_unreachable("Unknown address space in argument");
485 case PTXStateSpace::Global:
486 decl += " .global";
487 break;
488 case PTXStateSpace::Shared:
489 decl += " .shared";
490 break;
491 }
492 }
493 decl += " __param_";
494 decl += utostr(Counter++);
459495 }
460496 } else {
461497 for (PTXMachineFunctionInfo::reg_iterator
413413
414414 return Chain;
415415 }
416
417 unsigned PTXTargetLowering::getNumRegisters(LLVMContext &Context, EVT VT) {
418 // All arguments consist of one "register," regardless of the type.
419 return 1;
420 }
421
7474
7575 virtual EVT getSetCCResultType(EVT VT) const;
7676
77 virtual unsigned getNumRegisters(LLVMContext &Context, EVT VT);
78
7779 private:
7880 SDValue LowerGlobalAddress(SDValue Op, SelectionDAG &DAG) const;
7981 }; // class PTXTargetLowering
118118 (PTXTarget >= PTX_COMPUTE_2_0 && PTXTarget < PTX_LAST_COMPUTE);
119119 }
120120
121 bool emitPtrAttribute() const {
122 return PTXVersion >= PTX_VERSION_2_2;
123 }
124
121125 void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
122126 }; // class PTXSubtarget
123127 } // namespace llvm