diff options
author | Chris Lattner <sabre@nondot.org> | 2007-07-14 01:29:45 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2007-07-14 01:29:45 +0000 |
commit | d2d2a11a91d7ddf468bfb70f66362d24806ed601 (patch) | |
tree | 1920f1ccb6fc00b05bbd9d884dd821601d906626 /CodeGen/CodeGenTypes.cpp | |
parent | 8f32f7189b12f67aa4a19bc7c3855b599980eca0 (diff) |
A significant refactoring of the type size stuff to also
compute type alignment. This info is needed for struct layout.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39850 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'CodeGen/CodeGenTypes.cpp')
-rw-r--r-- | CodeGen/CodeGenTypes.cpp | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/CodeGen/CodeGenTypes.cpp b/CodeGen/CodeGenTypes.cpp index a75ac4ce75..5bae791080 100644 --- a/CodeGen/CodeGenTypes.cpp +++ b/CodeGen/CodeGenTypes.cpp @@ -19,6 +19,9 @@ using namespace clang; using namespace CodeGen; +CodeGenTypes::CodeGenTypes(ASTContext &Ctx) + : Context(Ctx), Target(Ctx.Target) { +} /// ConvertType - Convert the specified type to its LLVM form. const llvm::Type *CodeGenTypes::ConvertType(QualType T) { @@ -31,32 +34,26 @@ const llvm::Type *CodeGenTypes::ConvertType(QualType T) { case BuiltinType::Void: // LLVM void type can only be used as the result of a function call. Just // map to the same as char. - case BuiltinType::Char_S: - case BuiltinType::Char_U: - case BuiltinType::SChar: - case BuiltinType::UChar: - return llvm::IntegerType::get(Target.getCharWidth(SourceLocation())); + return llvm::IntegerType::get(8); case BuiltinType::Bool: // FIXME: This is very strange. We want scalars to be i1, but in memory // they can be i1 or i32. Should the codegen handle this issue? return llvm::Type::Int1Ty; + case BuiltinType::Char_S: + case BuiltinType::Char_U: + case BuiltinType::SChar: + case BuiltinType::UChar: case BuiltinType::Short: case BuiltinType::UShort: - return llvm::IntegerType::get(Target.getShortWidth(SourceLocation())); - case BuiltinType::Int: case BuiltinType::UInt: - return llvm::IntegerType::get(Target.getIntWidth(SourceLocation())); - case BuiltinType::Long: case BuiltinType::ULong: - return llvm::IntegerType::get(Target.getLongWidth(SourceLocation())); - case BuiltinType::LongLong: case BuiltinType::ULongLong: - return llvm::IntegerType::get(Target.getLongLongWidth(SourceLocation())); + return llvm::IntegerType::get(Context.getTypeSize(T, SourceLocation())); case BuiltinType::Float: return llvm::Type::FloatTy; case BuiltinType::Double: return llvm::Type::DoubleTy; |