[cfe-commits] PATCH: Add r600 TargetInfo
Tom Stellard
tom at stellard.net
Wed Oct 10 09:17:08 PDT 2012
On Tue, Oct 09, 2012 at 05:18:38PM -0700, Eli Friedman wrote:
> On Mon, Oct 1, 2012 at 12:25 PM, Tom Stellard <tom at stellard.net> wrote:
> > Hi,
> >
> > This patch adds r600 TargetInfo to Clang and makes it possible to
> > compile OpenCL C kernels for r600 using libclang.
> >
> > Please Review.
>
> + virtual const char * getVAListDeclaration() const {
> + return "";
> + }
>
> Unused.
>
> This is probably a bit too simple in the long-run, but it's fine for the moment.
>
Thanks for the review.
Here is an updated version of the patch. I don't have commit access, so
I will need someone to commit it for me.
Thanks,
Tom
-------------- next part --------------
diff --git lib/Basic/Targets.cpp lib/Basic/Targets.cpp
index 17f1a61..37aa5c3 100644
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -1177,6 +1177,71 @@ namespace {
}
namespace {
+
+static const unsigned R600AddrSpaceMap[] = {
+ 1, // opencl_global
+ 3, // opencl_local
+ 2, // opencl_constant
+ 1, // cuda_device
+ 2, // cuda_constant
+ 3 // cuda_shared
+};
+
+class R600TargetInfo : public TargetInfo {
+public:
+ R600TargetInfo(const std::string& triple) : TargetInfo(triple) {
+ DescriptionString =
+ "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16"
+ "-i32:32:32-i64:64:64-f32:32:32-f64:64:64-f80:32:32"
+ "-v16:16:16-v24:32:32-v32:32:32-v48:64:64-v64:64:64"
+ "-v96:128:128-v128:128:128-v192:256:256-v256:256:256"
+ "-v512:512:512-v1024:1024:1024-v2048:2048:2048"
+ "-n8:16:32:64";
+ AddrSpaceMap = &R600AddrSpaceMap;
+ }
+
+ virtual const char * getClobbers() const {
+ return "";
+ }
+
+ virtual void getGCCRegNames(const char * const *&Names,
+ unsigned &numNames) const {
+ Names = NULL;
+ numNames = 0;
+ }
+
+ virtual void getGCCRegAliases(const GCCRegAlias *&Aliases,
+ unsigned &NumAliases) const {
+ Aliases = NULL;
+ NumAliases = 0;
+ }
+
+ virtual bool validateAsmConstraint(const char *&Name,
+ TargetInfo::ConstraintInfo &info) const {
+ return true;
+ }
+
+ virtual void getTargetBuiltins(const Builtin::Info *&Records,
+ unsigned &NumRecords) const {
+ Records = NULL;
+ NumRecords = 0;
+ }
+
+
+ virtual void getTargetDefines(const LangOptions &Opts,
+ MacroBuilder &Builder) const {
+ Builder.defineMacro("__R600__");
+ }
+
+ virtual BuiltinVaListKind getBuiltinVaListKind() const {
+ return TargetInfo::CharPtrBuiltinVaList;
+ }
+
+};
+
+} // end anonymous namespace
+
+namespace {
// MBlaze abstract base class
class MBlazeTargetInfo : public TargetInfo {
static const char * const GCCRegNames[];
@@ -4378,6 +4443,9 @@ static TargetInfo *AllocateTarget(const std::string &T) {
case llvm::Triple::mblaze:
return new MBlazeTargetInfo(T);
+ case llvm::Triple::r600:
+ return new R600TargetInfo(T);
+
case llvm::Triple::sparc:
switch (os) {
case llvm::Triple::Linux:
More information about the cfe-commits
mailing list