diff options
author | Zonr Chang <zonr@google.com> | 2010-10-13 18:29:18 +0800 |
---|---|---|
committer | Zonr Chang <zonr@google.com> | 2010-10-13 18:29:18 +0800 |
commit | 41ebf534161bb67f6207a070c1f6a895dc853408 (patch) | |
tree | 182fe2380fd6ac26bda03d2c54179933c808ec38 | |
parent | e86245a09bb8b9e72f5dc68083444ec938865798 (diff) | |
download | android_frameworks_compile_slang-41ebf534161bb67f6207a070c1f6a895dc853408.tar.gz android_frameworks_compile_slang-41ebf534161bb67f6207a070c1f6a895dc853408.tar.bz2 android_frameworks_compile_slang-41ebf534161bb67f6207a070c1f6a895dc853408.zip |
Remove Slang::TargetDescription.
Clang and LLVM never read outside target description to configure the
target-dependent information needed during compilation and codegen. They
always use their own data layout string for specific, known target.
-rw-r--r-- | slang.cpp | 15 | ||||
-rw-r--r-- | slang.h | 2 | ||||
-rw-r--r-- | slang_backend.cpp | 27 | ||||
-rw-r--r-- | slang_backend.h | 4 | ||||
-rw-r--r-- | slang_rs.cpp | 1 | ||||
-rw-r--r-- | slang_rs_context.cpp | 5 | ||||
-rw-r--r-- | slang_rs_export_type.cpp | 16 | ||||
-rw-r--r-- | slang_rs_export_type_support.inc | 2 |
8 files changed, 25 insertions, 47 deletions
@@ -103,21 +103,6 @@ clang::LangOptions Slang::LangOpts; // Code generation option for the compiler clang::CodeGenOptions Slang::CodeGenOpts; -const std::string Slang::TargetDescription = - "e-" // little-endian - "p:32:32:32-" // 32-bit pointer - "i1:8:8-" - "i8:8:8-" - "i16:16:16-" - "i32:32:32-" - "i64:64:64-" - "f32:32:32-" - "f64:64:64-" - "v64:64:64-" // 64-bit vector (e.g. float2, int2, short4) - "v128:128:128-" - "a0:0:64-" - "n32"; // native CPU only support 32-bit integer width. - // The named of metadata node that pragma resides (should be synced with // bcc.cpp) const llvm::StringRef Slang::PragmaMetadataName = "#pragma"; @@ -147,8 +147,6 @@ class Slang { OutputType OT); public: - static const std::string TargetDescription; - static const llvm::StringRef PragmaMetadataName; static void GlobalInitialization(); diff --git a/slang_backend.cpp b/slang_backend.cpp index 2e153fa..e8242eb 100644 --- a/slang_backend.cpp +++ b/slang_backend.cpp @@ -20,6 +20,7 @@ #include "llvm/Metadata.h" #include "llvm/LLVMContext.h" +#include "llvm/Target/TargetData.h" #include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetOptions.h" #include "llvm/Target/TargetRegistry.h" @@ -51,7 +52,7 @@ using namespace slang; void Backend::CreateFunctionPasses() { if (!mPerFunctionPasses) { mPerFunctionPasses = new llvm::FunctionPassManager(mpModule); - mPerFunctionPasses->add(new llvm::TargetData(*mpTargetData)); + mPerFunctionPasses->add(new llvm::TargetData(mpModule)); llvm::createStandardFunctionPasses(mPerFunctionPasses, mCodeGenOpts.OptimizationLevel); @@ -62,7 +63,7 @@ void Backend::CreateFunctionPasses() { void Backend::CreateModulePasses() { if (!mPerModulePasses) { mPerModulePasses = new llvm::PassManager(); - mPerModulePasses->add(new llvm::TargetData(*mpTargetData)); + mPerModulePasses->add(new llvm::TargetData(mpModule)); llvm::createStandardModulePasses(mPerModulePasses, mCodeGenOpts.OptimizationLevel, @@ -85,7 +86,7 @@ bool Backend::CreateCodeGenPasses() { return true; } else { mCodeGenPasses = new llvm::FunctionPassManager(mpModule); - mCodeGenPasses->add(new llvm::TargetData(*mpTargetData)); + mCodeGenPasses->add(new llvm::TargetData(mpModule)); } // Create the TargetMachine for generating code. @@ -116,15 +117,14 @@ bool Backend::CreateCodeGenPasses() { llvm::TargetMachine::setRelocationModel(llvm::Reloc::Static); - // The target with pointer size greater than 32 (e.g. x86_64 architecture) may - // need large data address model - if (mpTargetData->getPointerSizeInBits() > 32) - llvm::TargetMachine::setCodeModel(llvm::CodeModel::Medium); - else - // This is set for the linker (specify how large of the virtual addresses we - // can access for all unknown symbols.) - + // This is set for the linker (specify how large of the virtual addresses we + // can access for all unknown symbols.) + if (mpModule->getPointerSize() == llvm::Module::Pointer32) llvm::TargetMachine::setCodeModel(llvm::CodeModel::Small); + else + // The target may have pointer size greater than 32 (e.g. x86_64 + // architecture) may need large data address model + llvm::TargetMachine::setCodeModel(llvm::CodeModel::Medium); // Setup feature string std::string FeaturesStr; @@ -184,7 +184,6 @@ Backend::Backend(clang::Diagnostic &Diags, mTargetOpts(TargetOpts), mpOS(OS), mOT(OT), - mpTargetData(NULL), mGen(NULL), mPerFunctionPasses(NULL), mPerModulePasses(NULL), @@ -203,7 +202,6 @@ void Backend::Initialize(clang::ASTContext &Ctx) { mGen->Initialize(Ctx); mpModule = mGen->GetModule(); - mpTargetData = new llvm::TargetData(Slang::TargetDescription); return; } @@ -221,7 +219,7 @@ void Backend::HandleTranslationUnit(clang::ASTContext &Ctx) { // or machine code, whatever.) // Silently ignore if we weren't initialized for some reason. - if (!mpModule || !mpTargetData) + if (!mpModule) return; llvm::Module *M = mGen->ReleaseModule(); @@ -328,7 +326,6 @@ void Backend::CompleteTentativeDefinition(clang::VarDecl *D) { Backend::~Backend() { delete mpModule; - delete mpTargetData; delete mGen; delete mPerFunctionPasses; delete mPerModulePasses; diff --git a/slang_backend.h b/slang_backend.h index 3ec3f30..6d1bf6d 100644 --- a/slang_backend.h +++ b/slang_backend.h @@ -19,8 +19,6 @@ #include "llvm/PassManager.h" -#include "llvm/Target/TargetData.h" - #include "llvm/Support/StandardPasses.h" #include "llvm/Support/FormattedStream.h" @@ -57,8 +55,6 @@ class Backend : public clang::ASTConsumer { llvm::raw_ostream *mpOS; Slang::OutputType mOT; - llvm::TargetData *mpTargetData; - // This helps us translate Clang AST using into LLVM IR clang::CodeGenerator *mGen; diff --git a/slang_rs.cpp b/slang_rs.cpp index c4495b6..0e03aa7 100644 --- a/slang_rs.cpp +++ b/slang_rs.cpp @@ -147,7 +147,6 @@ bool SlangRS::checkODR(const char *CurInputFile) { // Take the ownership of ERT such that it won't be freed in ~RSContext(). ERT->keep(); } - } return true; } diff --git a/slang_rs_context.cpp b/slang_rs_context.cpp index a63b2ad..bc6eb40 100644 --- a/slang_rs_context.cpp +++ b/slang_rs_context.cpp @@ -17,14 +17,17 @@ #include "slang_rs_context.h" #include "llvm/LLVMContext.h" + #include "llvm/Target/TargetData.h" #include "clang/Basic/TargetInfo.h" #include "clang/Basic/Linkage.h" + #include "clang/AST/Type.h" #include "clang/AST/Decl.h" #include "clang/AST/DeclBase.h" #include "clang/AST/ASTContext.h" + #include "clang/Index/ASTLocation.h" #include "slang.h" @@ -77,7 +80,7 @@ RSContext::RSContext(clang::Preprocessor *PP, "rs", RSPragmaHandler::CreatePragmaReflectLicenseHandler(this)); // Prepare target data - mTargetData = new llvm::TargetData(Slang::TargetDescription); + mTargetData = new llvm::TargetData(Target->getTargetDescription()); return; } diff --git a/slang_rs_export_type.cpp b/slang_rs_export_type.cpp index 416cdfa..cc95e63 100644 --- a/slang_rs_export_type.cpp +++ b/slang_rs_export_type.cpp @@ -720,10 +720,10 @@ const char* RSExportVectorType::VectorTypeNameStore[][3] = { /* 3 */ { "ushort2", "ushort3", "ushort4" }, /* 4 */ { "int2", "int3", "int4" }, /* 5 */ { "uint2", "uint3", "uint4" }, - /* 6 */ { "float2", "float3", "float4" }, - /* 7 */ { "double2", "double3", "double4" }, - /* 8 */ { "long2", "long3", "long4" }, - /* 9 */ { "ulong2", "ulong3", "ulong4" }, + /* 6 */ { "long2", "long3", "long4" }, + /* 7 */ { "ulong2", "ulong3", "ulong4" }, + /* 8 */ { "float2", "float3", "float4" }, + /* 9 */ { "double2", "double3", "double4" }, }; llvm::StringRef @@ -754,13 +754,13 @@ RSExportVectorType::GetTypeName(const clang::ExtVectorType *EVT) { BaseElement = VectorTypeNameStore[4]; \ else if (type == RSExportPrimitiveType::DataTypeUnsigned32) \ BaseElement = VectorTypeNameStore[5]; \ - else if (type == RSExportPrimitiveType::DataTypeFloat32) \ + else if (type == RSExportPrimitiveType::DataTypeSigned64) \ BaseElement = VectorTypeNameStore[6]; \ - else if (type == RSExportPrimitiveType::DataTypeFloat64) \ + else if (type == RSExportPrimitiveType::DataTypeUnsigned64) \ BaseElement = VectorTypeNameStore[7]; \ - else if (type == RSExportPrimitiveType::DataTypeSigned64) \ + else if (type == RSExportPrimitiveType::DataTypeFloat32) \ BaseElement = VectorTypeNameStore[8]; \ - else if (type == RSExportPrimitiveType::DataTypeUnsigned64) \ + else if (type == RSExportPrimitiveType::DataTypeFloat64) \ BaseElement = VectorTypeNameStore[9]; \ else if (type == RSExportPrimitiveType::DataTypeBoolean) \ BaseElement = VectorTypeNameStore[0]; \ diff --git a/slang_rs_export_type_support.inc b/slang_rs_export_type_support.inc index 5f9754b..10435c8 100644 --- a/slang_rs_export_type_support.inc +++ b/slang_rs_export_type_support.inc @@ -14,7 +14,7 @@ * limitations under the License. */ -// SLANG_RS_SUPPORT_BUILTIN_TYPE(builtin_type, bits, type) +// SLANG_RS_SUPPORT_BUILTIN_TYPE(builtin_type, type) #ifdef SLANG_RS_SUPPORT_BUILTIN_TYPE SLANG_RS_SUPPORT_BUILTIN_TYPE(clang::BuiltinType::Char_U, RSExportPrimitiveType::DataTypeUnsigned8) SLANG_RS_SUPPORT_BUILTIN_TYPE(clang::BuiltinType::UChar, RSExportPrimitiveType::DataTypeUnsigned8) |