aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChe-Liang Chiou <clchiou@gmail.com>2010-11-30 10:14:14 +0000
committerChe-Liang Chiou <clchiou@gmail.com>2010-11-30 10:14:14 +0000
commit21d8b9bcad1f058a4f2571dbc5a677e0ed95643e (patch)
treecd4dbec109470596b7f1de744893716d442db314
parentc459d06ae6aaf95454425f678c18b600c21c6f36 (diff)
ptx: add command-line options for gpu target and ptx version
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120423 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Target/PTX/PTXAsmPrinter.cpp18
-rw-r--r--test/CodeGen/PTX/options.ll6
2 files changed, 24 insertions, 0 deletions
diff --git a/lib/Target/PTX/PTXAsmPrinter.cpp b/lib/Target/PTX/PTXAsmPrinter.cpp
index 03f177b2fa..8fb1f53d2b 100644
--- a/lib/Target/PTX/PTXAsmPrinter.cpp
+++ b/lib/Target/PTX/PTXAsmPrinter.cpp
@@ -27,12 +27,21 @@
#include "llvm/MC/MCSymbol.h"
#include "llvm/Target/TargetLoweringObjectFile.h"
#include "llvm/Target/TargetRegistry.h"
+#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/raw_ostream.h"
using namespace llvm;
+static cl::opt<std::string>
+OptPTXVersion("ptx-version", cl::desc("Set PTX version"),
+ cl::init("1.4"));
+
+static cl::opt<std::string>
+OptPTXTarget("ptx-target", cl::desc("Set GPU target (comma-separated list)"),
+ cl::init("sm_10"));
+
namespace {
class PTXAsmPrinter : public AsmPrinter {
public:
@@ -41,6 +50,8 @@ public:
const char *getPassName() const { return "PTX Assembly Printer"; }
+ virtual void EmitStartOfAsmFile(Module &M);
+
virtual bool runOnMachineFunction(MachineFunction &MF);
virtual void EmitFunctionBodyStart();
@@ -85,6 +96,13 @@ static const char *getInstructionTypeName(const MachineInstr *MI) {
return NULL;
}
+void PTXAsmPrinter::EmitStartOfAsmFile(Module &M)
+{
+ OutStreamer.EmitRawText(Twine("\t.version " + OptPTXVersion));
+ OutStreamer.EmitRawText(Twine("\t.target " + OptPTXTarget));
+ OutStreamer.AddBlankLine();
+}
+
bool PTXAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
SetupMachineFunction(MF);
EmitFunctionDeclaration();
diff --git a/test/CodeGen/PTX/options.ll b/test/CodeGen/PTX/options.ll
new file mode 100644
index 0000000000..a14d5c9c27
--- /dev/null
+++ b/test/CodeGen/PTX/options.ll
@@ -0,0 +1,6 @@
+; RUN: llc < %s -march=ptx -ptx-version=2.0 | grep ".version 2.0"
+; RUN: llc < %s -march=ptx -ptx-target=sm_20 | grep ".target sm_20"
+
+define ptx_device void @t1() {
+ ret void
+}