[llvm-commits] [llvm] r120423 - in /llvm/trunk: lib/Target/PTX/PTXAsmPrinter.cpp test/CodeGen/PTX/options.ll
Che-Liang Chiou
clchiou at gmail.com
Tue Nov 30 02:14:14 PST 2010
Author: clchiou
Date: Tue Nov 30 04:14:14 2010
New Revision: 120423
URL: http://llvm.org/viewvc/llvm-project?rev=120423&view=rev
Log:
ptx: add command-line options for gpu target and ptx version
Added:
llvm/trunk/test/CodeGen/PTX/options.ll
Modified:
llvm/trunk/lib/Target/PTX/PTXAsmPrinter.cpp
Modified: llvm/trunk/lib/Target/PTX/PTXAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTXAsmPrinter.cpp?rev=120423&r1=120422&r2=120423&view=diff
==============================================================================
--- llvm/trunk/lib/Target/PTX/PTXAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/PTX/PTXAsmPrinter.cpp Tue Nov 30 04:14:14 2010
@@ -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 @@
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 @@
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();
Added: llvm/trunk/test/CodeGen/PTX/options.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PTX/options.ll?rev=120423&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/PTX/options.ll (added)
+++ llvm/trunk/test/CodeGen/PTX/options.ll Tue Nov 30 04:14:14 2010
@@ -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
+}
More information about the llvm-commits
mailing list