summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorKen Dyck <ken.dyck@onsemi.com>2010-01-26 17:22:55 +0000
committerKen Dyck <ken.dyck@onsemi.com>2010-01-26 17:22:55 +0000
commit24d28d6cde4a36b6f4d05ef153fa5f58f6709861 (patch)
treefe641f4d8d85a243096a7e59fab36a240560d9a5 /clang
parent27b4fa994d7bf7a9a5c49ffc860e60b814985957 (diff)
downloadbcm5719-llvm-24d28d6cde4a36b6f4d05ef153fa5f58f6709861.tar.gz
bcm5719-llvm-24d28d6cde4a36b6f4d05ef153fa5f58f6709861.zip
Add getTypeAlignInChars() for use in code that works in alignments in character
units. llvm-svn: 94552
Diffstat (limited to 'clang')
-rw-r--r--clang/include/clang/AST/ASTContext.h5
-rw-r--r--clang/lib/AST/ASTContext.cpp9
2 files changed, 14 insertions, 0 deletions
diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h
index e5429bec143..0462de3897a 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -835,6 +835,11 @@ public:
return getTypeInfo(T).second;
}
+ /// getTypeAlign - Return the ABI-specified alignment of a type, in
+ /// characters. This method does not work on incomplete types.
+ CharUnits getTypeAlignInChars(QualType T);
+ CharUnits getTypeAlignInChars(const Type *T);
+
/// getPreferredTypeAlign - Return the "preferred" alignment of the specified
/// type for the current target in bits. This can be different than the ABI
/// alignment in cases where it is beneficial for performance to overalign
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index c1bc70989d4..e5c4381530f 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -820,6 +820,15 @@ CharUnits ASTContext::getTypeSizeInChars(const Type *T) {
return CharUnits::fromQuantity(getTypeSize(T) / getCharWidth());
}
+/// getTypeAlign - Return the ABI-specified alignment of a type, in
+/// characters. This method does not work on incomplete types.
+CharUnits ASTContext::getTypeAlignInChars(QualType T) {
+ return CharUnits::fromQuantity(getTypeAlign(T) / getCharWidth());
+}
+CharUnits ASTContext::getTypeAlignInChars(const Type *T) {
+ return CharUnits::fromQuantity(getTypeAlign(T) / getCharWidth());
+}
+
/// getPreferredTypeAlign - Return the "preferred" alignment of the specified
/// type for the current target in bits. This can be different than the ABI
/// alignment in cases where it is beneficial for performance to overalign
OpenPOWER on IntegriCloud