mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Add Builtin.Word and use it to implement swift.Word.
Swift SVN r9864
This commit is contained in:
@@ -46,6 +46,11 @@ bool IntrinsicInfo::hasAttribute(llvm::Attribute::AttrKind Kind) const {
|
||||
return (attrs.hasAttribute(llvm::AttributeSet::FunctionIndex, Kind));
|
||||
}
|
||||
|
||||
static Type getPointerSizeType(ASTContext &Context) {
|
||||
// FIXME: Size of a pointer here?
|
||||
return BuiltinIntegerType::get(64, Context);
|
||||
}
|
||||
|
||||
Type swift::getBuiltinType(ASTContext &Context, StringRef Name) {
|
||||
// Vectors are VecNxT, where "N" is the number of elements and
|
||||
// T is the element type.
|
||||
@@ -79,6 +84,9 @@ Type swift::getBuiltinType(ASTContext &Context, StringRef Name) {
|
||||
if (Name == "FPIEEE64")
|
||||
return Context.TheIEEE64Type;
|
||||
|
||||
if (Name == "Word")
|
||||
return getPointerSizeType(Context);
|
||||
|
||||
// Handle 'int8' and friends.
|
||||
if (Name.substr(0, 3) == "Int") {
|
||||
unsigned BitWidth;
|
||||
@@ -271,11 +279,14 @@ static ValueDecl *getCastOperation(ASTContext &Context, Identifier Id,
|
||||
// the "isBuiltinTypeOverloaded" predicate successfully.
|
||||
switch (VK) {
|
||||
default: assert(0 && "Not a cast operation");
|
||||
|
||||
// Allow trunc/zext/sext of identical bit widths (i.e. a no-op)
|
||||
// because it simplifies interfacing Word with Int32 and Int64.
|
||||
case BuiltinValueKind::Trunc:
|
||||
if (CheckOutput.isNull() ||
|
||||
!CheckInput->is<BuiltinIntegerType>() ||
|
||||
!CheckOutput->is<BuiltinIntegerType>() ||
|
||||
CheckInput->castTo<BuiltinIntegerType>()->getBitWidth() <=
|
||||
CheckInput->castTo<BuiltinIntegerType>()->getBitWidth() <
|
||||
CheckOutput->castTo<BuiltinIntegerType>()->getBitWidth())
|
||||
return nullptr;
|
||||
break;
|
||||
@@ -285,7 +296,7 @@ static ValueDecl *getCastOperation(ASTContext &Context, Identifier Id,
|
||||
if (CheckOutput.isNull() ||
|
||||
!CheckInput->is<BuiltinIntegerType>() ||
|
||||
!CheckOutput->is<BuiltinIntegerType>() ||
|
||||
CheckInput->castTo<BuiltinIntegerType>()->getBitWidth() >=
|
||||
CheckInput->castTo<BuiltinIntegerType>()->getBitWidth() >
|
||||
CheckOutput->castTo<BuiltinIntegerType>()->getBitWidth())
|
||||
return nullptr;
|
||||
break;
|
||||
@@ -427,11 +438,6 @@ static ValueDecl *getDestroyOperation(ASTContext &Context, Identifier Id) {
|
||||
ResultTy, ResultTy, ParamList);
|
||||
}
|
||||
|
||||
static Type getPointerSizeType(ASTContext &Context) {
|
||||
// FIXME: Size of a pointer here?
|
||||
return BuiltinIntegerType::get(64, Context);
|
||||
}
|
||||
|
||||
static ValueDecl *getSizeOrAlignOfOperation(ASTContext &Context,
|
||||
Identifier Id) {
|
||||
Type GenericTy;
|
||||
|
||||
Reference in New Issue
Block a user