forked from OSchip/llvm-project
parent
e3fb4b6524
commit
b5b703b2f7
|
@ -1366,6 +1366,72 @@ namespace {
|
|||
}
|
||||
|
||||
|
||||
namespace {
|
||||
class SystemZTargetInfo : public TargetInfo {
|
||||
static const char * const GCCRegNames[];
|
||||
public:
|
||||
SystemZTargetInfo(const std::string& triple) : TargetInfo(triple) {
|
||||
TLSSupported = false;
|
||||
IntWidth = IntAlign = 32;
|
||||
LongWidth = LongLongWidth = LongAlign = LongLongAlign = 64;
|
||||
PointerWidth = PointerAlign = 64;
|
||||
DescriptionString = "E-p:64:64:64-i8:8:16-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-f128:128:128-a0:16:16";
|
||||
}
|
||||
virtual void getTargetDefines(const LangOptions &Opts,
|
||||
std::vector<char> &Defines) const {
|
||||
Define(Defines, "__s390__");
|
||||
Define(Defines, "__s390x__");
|
||||
}
|
||||
virtual void getTargetBuiltins(const Builtin::Info *&Records,
|
||||
unsigned &NumRecords) const {
|
||||
// FIXME: Implement.
|
||||
Records = 0;
|
||||
NumRecords = 0;
|
||||
}
|
||||
virtual const char *getTargetPrefix() const {
|
||||
return "s390x";
|
||||
}
|
||||
|
||||
virtual void getDefaultLangOptions(LangOptions &Opts) {
|
||||
TargetInfo::getDefaultLangOptions(Opts);
|
||||
Opts.CharIsSigned = false;
|
||||
}
|
||||
|
||||
virtual void getGCCRegNames(const char * const *&Names,
|
||||
unsigned &NumNames) const;
|
||||
virtual void getGCCRegAliases(const GCCRegAlias *&Aliases,
|
||||
unsigned &NumAliases) const {
|
||||
// No aliases.
|
||||
Aliases = 0;
|
||||
NumAliases = 0;
|
||||
}
|
||||
virtual bool validateAsmConstraint(const char *&Name,
|
||||
TargetInfo::ConstraintInfo &info) const {
|
||||
// FIXME: implement
|
||||
return true;
|
||||
}
|
||||
virtual const char *getClobbers() const {
|
||||
// FIXME: Is this really right?
|
||||
return "";
|
||||
}
|
||||
virtual const char *getVAListDeclaration() const {
|
||||
// FIXME: implement
|
||||
return "typedef char* __builtin_va_list;";
|
||||
}
|
||||
};
|
||||
|
||||
const char * const SystemZTargetInfo::GCCRegNames[] = {
|
||||
"r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
|
||||
"r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15"
|
||||
};
|
||||
|
||||
void SystemZTargetInfo::getGCCRegNames(const char * const *&Names,
|
||||
unsigned &NumNames) const {
|
||||
Names = GCCRegNames;
|
||||
NumNames = llvm::array_lengthof(GCCRegNames);
|
||||
}
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Driver code
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
@ -1439,6 +1505,9 @@ TargetInfo* TargetInfo::CreateTargetInfo(const std::string &T) {
|
|||
if (T.find("msp430-") == 0)
|
||||
return new MSP430TargetInfo(T);
|
||||
|
||||
if (T.find("s390x-") == 0)
|
||||
return new SystemZTargetInfo(T);
|
||||
|
||||
if (IsX86(T)) {
|
||||
if (isDarwin)
|
||||
return new DarwinI386TargetInfo(T);
|
||||
|
|
|
@ -1419,6 +1419,81 @@ ABIArgInfo DefaultABIInfo::classifyReturnType(QualType RetTy,
|
|||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
class SystemZABIInfo : public ABIInfo {
|
||||
bool isPromotableIntegerType(QualType Ty) const;
|
||||
|
||||
ABIArgInfo classifyReturnType(QualType RetTy, ASTContext &Context,
|
||||
llvm::LLVMContext &VMContext) const;
|
||||
|
||||
ABIArgInfo classifyArgumentType(QualType RetTy, ASTContext &Context,
|
||||
llvm::LLVMContext &VMContext) const;
|
||||
|
||||
virtual void computeInfo(CGFunctionInfo &FI, ASTContext &Context,
|
||||
llvm::LLVMContext &VMContext) const {
|
||||
FI.getReturnInfo() = classifyReturnType(FI.getReturnType(),
|
||||
Context, VMContext);
|
||||
for (CGFunctionInfo::arg_iterator it = FI.arg_begin(), ie = FI.arg_end();
|
||||
it != ie; ++it)
|
||||
it->info = classifyArgumentType(it->type, Context, VMContext);
|
||||
}
|
||||
|
||||
virtual llvm::Value *EmitVAArg(llvm::Value *VAListAddr, QualType Ty,
|
||||
CodeGenFunction &CGF) const;
|
||||
};
|
||||
}
|
||||
|
||||
bool SystemZABIInfo::isPromotableIntegerType(QualType Ty) const {
|
||||
// SystemZ ABI requires all 8, 16 and 32 bit quantities to be extended.
|
||||
if (const BuiltinType *BT = Ty->getAsBuiltinType())
|
||||
switch (BT->getKind()) {
|
||||
case BuiltinType::Bool:
|
||||
case BuiltinType::Char_S:
|
||||
case BuiltinType::Char_U:
|
||||
case BuiltinType::SChar:
|
||||
case BuiltinType::UChar:
|
||||
case BuiltinType::Short:
|
||||
case BuiltinType::UShort:
|
||||
case BuiltinType::Int:
|
||||
case BuiltinType::UInt:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
llvm::Value *SystemZABIInfo::EmitVAArg(llvm::Value *VAListAddr, QualType Ty,
|
||||
CodeGenFunction &CGF) const {
|
||||
// FIXME: Implement
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
ABIArgInfo SystemZABIInfo::classifyReturnType(QualType RetTy,
|
||||
ASTContext &Context,
|
||||
llvm::LLVMContext &VMContext) const {
|
||||
if (RetTy->isVoidType()) {
|
||||
return ABIArgInfo::getIgnore();
|
||||
} else if (CodeGenFunction::hasAggregateLLVMType(RetTy)) {
|
||||
return ABIArgInfo::getIndirect(0);
|
||||
} else {
|
||||
return (isPromotableIntegerType(RetTy) ?
|
||||
ABIArgInfo::getExtend() : ABIArgInfo::getDirect());
|
||||
}
|
||||
}
|
||||
|
||||
ABIArgInfo SystemZABIInfo::classifyArgumentType(QualType Ty,
|
||||
ASTContext &Context,
|
||||
llvm::LLVMContext &VMContext) const {
|
||||
if (CodeGenFunction::hasAggregateLLVMType(Ty)) {
|
||||
return ABIArgInfo::getIndirect(0);
|
||||
} else {
|
||||
return (isPromotableIntegerType(Ty) ?
|
||||
ABIArgInfo::getExtend() : ABIArgInfo::getDirect());
|
||||
}
|
||||
}
|
||||
|
||||
ABIArgInfo DefaultABIInfo::classifyArgumentType(QualType Ty,
|
||||
ASTContext &Context,
|
||||
llvm::LLVMContext &VMContext) const {
|
||||
|
@ -1455,6 +1530,8 @@ const ABIInfo &CodeGenTypes::getABIInfo() const {
|
|||
return *(TheABIInfo = new ARMABIInfo());
|
||||
} else if (strcmp(TargetPrefix, "pic16") == 0) {
|
||||
return *(TheABIInfo = new PIC16ABIInfo());
|
||||
} else if (strcmp(TargetPrefix, "s390x") == 0) {
|
||||
return *(TheABIInfo = new SystemZABIInfo());
|
||||
}
|
||||
|
||||
return *(TheABIInfo = new DefaultABIInfo);
|
||||
|
|
Loading…
Reference in New Issue