PTX target for LLVM!

Hey everybody,

good news for everyone interested in the PTX backend:
We decided to release the current source code under the GPL - you can
find the latest tarball here:

http://www.prog.uni-saarland.de/projects/anysl

You will find the README in the attachment, which should hopefully
answer a lot of questions concerning the implementation and the current
status.

If you have further questions, comments, or suggestions, feel free to
contact us directly or respond on the list.

We would also like to know if there are any major obstacles to merging
the code into LLVM trunk (apart from coding standards :wink: ).

Best regards,
Helge Rhodin and Ralf Karrenberg

README (5.27 KB)

Hello, Helge

We would also like to know if there are any major obstacles to merging
the code into LLVM trunk (apart from coding standards :wink: ).

Mmmm.... license?

Yep. GPL is going to make this unmergeable.

                        -Dave

It would be great to have this in LLVM mainline. As others have pointed out though, we can only do this is you’re willing to license the code under the UIUC license. More specific terms are described here:
http://llvm.org/docs/DeveloperPolicy.html

More specifically:
http://llvm.org/docs/DeveloperPolicy.html#license

Are you willing to release this under the UIUC license? If not, unfortunately we can’t include it in the LLVM distros, which would be a real shame :frowning:

-Chris

Hi everyone,
I downloaded the latest version of LLVM PTX backend from
http://www.prog.uni-saarland.de/projects/anysl
and made the required changes to all the files mentioned in the README. But
I get the following error when I compile it.
llvm[3]: Compiling PTXBackend.cpp for Release build
In file included from PTXBackend.h:70:0,
                 from PTXBackend.cpp:36:
PTXPasses.h: In constructor
‘PTXBackendInsertSpecialInstructions::PTXBackendInsertSpecialInstructions(std::map<const
llvm::Value*, const llvm::Value*>&)’:
PTXPasses.h:93:63: error: no matching function for call to
‘llvm::BasicBlockPass::BasicBlockPass(char*)’
/home/neelima/Documents/llvm-2.9/include/llvm/Pass.h:321:12: note:
candidates are: llvm::BasicBlockPass::BasicBlockPass(char&)
/home/neelima/Documents/llvm-2.9/include/llvm/Pass.h:319:36: note:
llvm::BasicBlockPass::BasicBlockPass(const llvm::BasicBlockPass&)
PTXPasses.h: In constructor
‘PTXPolishBeforeCodegenPass::PTXPolishBeforeCodegenPass()’:
PTXPasses.h:151:24: error: no matching function for call to
‘llvm::BasicBlockPass::BasicBlockPass(char*)’
/home/neelima/Documents/llvm-2.9/include/llvm/Pass.h:321:12: note:
candidates are: llvm::BasicBlockPass::BasicBlockPass(char&)
/home/neelima/Documents/llvm-2.9/include/llvm/Pass.h:319:36: note:
llvm::BasicBlockPass::BasicBlockPass(const llvm::BasicBlockPass&)
PTXPasses.h: In constructor
‘PTXBackendNameAllUsedStructsAndMergeFunctions::PTXBackendNameAllUsedStructsAndMergeFunctions()’:
PTXPasses.h:197:21: error: no matching function for call to
‘llvm::ModulePass::ModulePass(char*)’
/home/neelima/Documents/llvm-2.9/include/llvm/Pass.h:235:12: note:
candidates are: llvm::ModulePass::ModulePass(char&)
/home/neelima/Documents/llvm-2.9/include/llvm/Pass.h:220:32: note:
llvm::ModulePass::ModulePass(const llvm::ModulePass&)
In file included from PTXBackend.cpp:36:0:
PTXBackend.h: In constructor
‘PTXWriter::PTXWriter(llvm::formatted_raw_ostream&, std::map<const
llvm::Value*, const llvm::Value*>&)’:
PTXBackend.h:114:30: error: no matching function for call to
‘llvm::FunctionPass::FunctionPass(char*)’
/home/neelima/Documents/llvm-2.9/include/llvm/Pass.h:280:12: note:
candidates are: llvm::FunctionPass::FunctionPass(char&)
/home/neelima/Documents/llvm-2.9/include/llvm/Pass.h:278:34: note:
llvm::FunctionPass::FunctionPass(const llvm::FunctionPass&)
PTXBackend.h: In member function ‘bool PTXWriter::isAddressExposed(const
llvm::Value*) const’:
PTXBackend.h:386:5: warning: no return statement in function returning
non-void
PTXBackend.h: In static member function ‘static bool
PTXWriter::isInlinableInst(const llvm::Instruction&)’:
PTXBackend.h:395:5: warning: no return statement in function returning
non-void
PTXBackend.h: In member function ‘std::string
PTXWriter::getAddressSpace(const llvm::Value*)’:
PTXBackend.h:556:40: error: ‘const class llvm::Value’ has no member named
‘getUnderlyingObject’
PTXBackend.cpp: In member function ‘virtual bool
PTXWriter::doInitialization(llvm::Module&)’:
PTXBackend.cpp:432:29: error: no matching function for call to
‘llvm::MCContext::MCContext(const llvm::MCAsmInfo&)’
/home/neelima/Documents/llvm-2.9/include/llvm/MC/MCContext.h:105:14: note:
candidates are: llvm::MCContext::MCContext(const llvm::MCAsmInfo&, const
llvm::TargetAsmInfo*)
/home/neelima/Documents/llvm-2.9/include/llvm/MC/MCContext.h:40:5: note:
llvm::MCContext::MCContext(const llvm::MCContext&)
PTXBackend.cpp: In member function ‘std::string
PTXWriter::getOperandStr(const llvm::Value*)’:
PTXBackend.cpp:379:1: warning: control reaches end of non-void function
/bin/rm: cannot remove
`/home/neelima/Documents/llvm-2.9/lib/Target/PTXBackend/Release/PTXBackend.d.tmp':
No such file or directory
make[3]: ***
[/home/neelima/Documents/llvm-2.9/lib/Target/PTXBackend/Release/PTXBackend.o]
Error 1
make[3]: Leaving directory
`/home/neelima/Documents/llvm-2.9/lib/Target/PTXBackend'
make[2]: *** [PTXBackend/.makeall] Error 2
make[2]: Leaving directory `/home/neelima/Documents/llvm-2.9/lib/Target'
make[1]: *** [Target/.makeall] Error 2
make[1]: Leaving directory `/home/neelima/Documents/llvm-2.9/lib'
make: *** [all] Error 1

Sorry to post such a large piece of the debug info, but i am a beginner and
do not know which part will help in debugging it.
Thank You:)

Helge Rhodin wrote:

Hi everyone,
I downloaded the latest version of LLVM PTX backend from
http://www.prog.uni-saarland.de/projects/anysl
and made the required changes to all the files mentioned in the README. But
I get the following error when I compile it.
llvm[3]: Compiling PTXBackend.cpp for Release build
In file included from PTXBackend.h:70:0,
from PTXBackend.cpp:36:
PTXPasses.h: In constructor
‘PTXBackendInsertSpecialInstructions::PTXBackendInsertSpecialInstructions(std::map<const
llvm::Value*, const llvm::Value*>&)’:
PTXPasses.h:93:63: error: no matching function for call to
‘llvm::BasicBlockPass::BasicBlockPass(char*)’
/home/neelima/Documents/llvm-2.9/include/llvm/Pass.h:321:12: note:
candidates are: llvm::BasicBlockPass::BasicBlockPass(char&)
/home/neelima/Documents/llvm-2.9/include/llvm/Pass.h:319:36: note:
llvm::BasicBlockPass::BasicBlockPass(const llvm::BasicBlockPass&)
PTXPasses.h: In constructor
‘PTXPolishBeforeCodegenPass::PTXPolishBeforeCodegenPass()’:
PTXPasses.h:151:24: error: no matching function for call to
‘llvm::BasicBlockPass::BasicBlockPass(char*)’
/home/neelima/Documents/llvm-2.9/include/llvm/Pass.h:321:12: note:
candidates are: llvm::BasicBlockPass::BasicBlockPass(char&)
/home/neelima/Documents/llvm-2.9/include/llvm/Pass.h:319:36: note:
llvm::BasicBlockPass::BasicBlockPass(const llvm::BasicBlockPass&)
PTXPasses.h: In constructor
‘PTXBackendNameAllUsedStructsAndMergeFunctions::PTXBackendNameAllUsedStructsAndMergeFunctions()’:
PTXPasses.h:197:21: error: no matching function for call to
‘llvm::ModulePass::ModulePass(char*)’
/home/neelima/Documents/llvm-2.9/include/llvm/Pass.h:235:12: note:
candidates are: llvm::ModulePass::ModulePass(char&)
/home/neelima/Documents/llvm-2.9/include/llvm/Pass.h:220:32: note:
llvm::ModulePass::ModulePass(const llvm::ModulePass&)
In file included from PTXBackend.cpp:36:0:
PTXBackend.h: In constructor
‘PTXWriter::PTXWriter(llvm::formatted_raw_ostream&, std::map<const
llvm::Value*, const llvm::Value*>&)’:
PTXBackend.h:114:30: error: no matching function for call to
‘llvm::FunctionPass::FunctionPass(char*)’
/home/neelima/Documents/llvm-2.9/include/llvm/Pass.h:280:12: note:
candidates are: llvm::FunctionPass::FunctionPass(char&)
/home/neelima/Documents/llvm-2.9/include/llvm/Pass.h:278:34: note:
llvm::FunctionPass::FunctionPass(const llvm::FunctionPass&)
PTXBackend.h: In member function ‘bool PTXWriter::isAddressExposed(const
llvm::Value*) const’:
PTXBackend.h:386:5: warning: no return statement in function returning
non-void
PTXBackend.h: In static member function ‘static bool
PTXWriter::isInlinableInst(const llvm::Instruction&)’:
PTXBackend.h:395:5: warning: no return statement in function returning
non-void
PTXBackend.h: In member function ‘std::string
PTXWriter::getAddressSpace(const llvm::Value*)’:
PTXBackend.h:556:40: error: ‘const class llvm::Value’ has no member named
‘getUnderlyingObject’
PTXBackend.cpp: In member function ‘virtual bool
PTXWriter::doInitialization(llvm::Module&)’:
PTXBackend.cpp:432:29: error: no matching function for call to
‘llvm::MCContext::MCContext(const llvm::MCAsmInfo&)’
/home/neelima/Documents/llvm-2.9/include/llvm/MC/MCContext.h:105:14: note:
candidates are: llvm::MCContext::MCContext(const llvm::MCAsmInfo&, const
llvm::TargetAsmInfo*)
/home/neelima/Documents/llvm-2.9/include/llvm/MC/MCContext.h:40:5: note:
llvm::MCContext::MCContext(const llvm::MCContext&)
PTXBackend.cpp: In member function ‘std::string
PTXWriter::getOperandStr(const llvm::Value*)’:
PTXBackend.cpp:379:1: warning: control reaches end of non-void function
/bin/rm: cannot remove
/home/neelima/Documents/llvm-2.9/lib/Target/PTXBackend/Release/PTXBackend.d.tmp': No such file or directory make[3]: *** [/home/neelima/Documents/llvm-2.9/lib/Target/PTXBackend/Release/PTXBackend.o] Error 1 make[3]: Leaving directory /home/neelima/Documents/llvm-2.9/lib/Target/PTXBackend’
make[2]: *** [PTXBackend/.makeall] Error 2
make[2]: Leaving directory /home/neelima/Documents/llvm-2.9/lib/Target' make[1]: *** [Target/.makeall] Error 2 make[1]: Leaving directory /home/neelima/Documents/llvm-2.9/lib’
make: *** [all] Error 1

Sorry to post such a large piece of the debug info, but i am a beginner and
do not know which part will help in debugging it.
Thank You:)

Looks like a version conflict between your local LLVM sources and the LLVM version this was written against. I would ask them to give you a specific LLVM revision number, then you can check out that specific version.

Also, depending on what you need, LLVM now has a built-in PTX back-end. It’s not quite robust yet, but it is capable of compiling a wide range of compute code.