add TCE target support, patch by Pekka J!

llvm-svn: 97746
This commit is contained in:
Chris Lattner 2010-03-04 21:07:38 +00:00
parent cf6e29a818
commit 09797543bd
6 changed files with 136 additions and 3 deletions

View File

@ -80,6 +80,8 @@ const HostInfo *createDragonFlyHostInfo(const Driver &D,
const llvm::Triple& Triple);
const HostInfo *createLinuxHostInfo(const Driver &D,
const llvm::Triple& Triple);
const HostInfo *createTCEHostInfo(const Driver &D,
const llvm::Triple& Triple);
const HostInfo *createUnknownHostInfo(const Driver &D,
const llvm::Triple& Triple);

View File

@ -1908,9 +1908,10 @@ namespace {
FloatFormat = &llvm::APFloat::IEEEsingle;
DoubleFormat = &llvm::APFloat::IEEEsingle;
LongDoubleFormat = &llvm::APFloat::IEEEsingle;
DescriptionString = "E-p:32:32:32-a0:32:32"
"-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64"
"-f32:32:32-f64:32:64-n32";
DescriptionString = "E-p:32:32:32-i1:8:8-i8:8:32-"
"i16:16:32-i32:32:32-i64:32:32-"
"f32:32:32-f64:64:64-v64:64:64-"
"v128:128:128-a0:0:64-n32";
}
virtual void getTargetDefines(const LangOptions &Opts,

View File

@ -1145,6 +1145,10 @@ const HostInfo *Driver::GetHostInfo(const char *TripleStr) const {
llvm::PrettyStackTraceString CrashInfo("Constructing host");
llvm::Triple Triple(TripleStr);
// TCE is an osless target
if (Triple.getArchName() == "tce")
return createTCEHostInfo(*this, Triple);
switch (Triple.getOS()) {
case llvm::Triple::AuroraUX:
return createAuroraUXHostInfo(*this, Triple);

View File

@ -157,6 +157,46 @@ ToolChain *DarwinHostInfo::CreateToolChain(const ArgList &Args,
return TC;
}
// TCE Host Info
/// TCEHostInfo - TCE host information implementation (see http://tce.cs.tut.fi)
class TCEHostInfo : public HostInfo {
public:
TCEHostInfo(const Driver &D, const llvm::Triple &Triple);
~TCEHostInfo() {};
virtual bool useDriverDriver() const;
virtual types::ID lookupTypeForExtension(const char *Ext) const {
types::ID Ty = types::lookupTypeForExtension(Ext);
if (Ty == types::TY_PP_Asm)
return types::TY_Asm;
return Ty;
}
virtual ToolChain *CreateToolChain(const ArgList &Args,
const char *ArchName) const;
};
TCEHostInfo::TCEHostInfo(const Driver &D, const llvm::Triple& Triple)
: HostInfo(D, Triple) {
}
bool TCEHostInfo::useDriverDriver() const {
return false;
}
ToolChain *TCEHostInfo::CreateToolChain(const ArgList &Args,
const char *ArchName) const {
llvm::Triple TCTriple(getTriple());
// TCTriple.setArchName(ArchName);
return new toolchains::TCEToolChain(*this, TCTriple);
}
// Unknown Host Info
/// UnknownHostInfo - Generic host information to use for unknown hosts.
@ -535,6 +575,12 @@ clang::driver::createLinuxHostInfo(const Driver &D,
return new LinuxHostInfo(D, Triple);
}
const HostInfo *
clang::driver::createTCEHostInfo(const Driver &D,
const llvm::Triple& Triple) {
return new TCEHostInfo(D, Triple);
}
const HostInfo *
clang::driver::createUnknownHostInfo(const Driver &D,
const llvm::Triple& Triple) {

View File

@ -728,6 +728,66 @@ DerivedArgList *Generic_GCC::TranslateArgs(InputArgList &Args,
return new DerivedArgList(Args, true);
}
/// TCEToolChain - A tool chain using the llvm bitcode tools to perform
/// all subcommands. See http://tce.cs.tut.fi for our peculiar target.
/// Currently does not support anything else but compilation.
TCEToolChain::TCEToolChain(const HostInfo &Host, const llvm::Triple& Triple)
: ToolChain(Host, Triple) {
// Path mangling to find libexec
std::string Path(getDriver().Dir);
Path += "/../libexec";
getProgramPaths().push_back(Path);
}
TCEToolChain::~TCEToolChain() {
for (llvm::DenseMap<unsigned, Tool*>::iterator
it = Tools.begin(), ie = Tools.end(); it != ie; ++it)
delete it->second;
}
bool TCEToolChain::IsMathErrnoDefault() const {
return true;
}
bool TCEToolChain::IsUnwindTablesDefault() const {
return false;
}
const char *TCEToolChain::GetDefaultRelocationModel() const {
return "static";
}
const char *TCEToolChain::GetForcedPicModel() const {
return 0;
}
Tool &TCEToolChain::SelectTool(const Compilation &C,
const JobAction &JA) const {
Action::ActionClass Key;
Key = Action::AnalyzeJobClass;
Tool *&T = Tools[Key];
if (!T) {
switch (Key) {
case Action::PreprocessJobClass:
T = new tools::gcc::Preprocess(*this); break;
case Action::AnalyzeJobClass:
T = new tools::Clang(*this); break;
default:
assert(false && "Unsupported action for TCE target.");
}
}
return *T;
}
DerivedArgList *TCEToolChain::TranslateArgs(InputArgList &Args,
const char *BoundArch) const {
return new DerivedArgList(Args, true);
}
/// OpenBSD - OpenBSD tool chain which can call as(1) and ld(1) directly.
OpenBSD::OpenBSD(const HostInfo &Host, const llvm::Triple& Triple)

View File

@ -267,6 +267,26 @@ public:
};
/// TCEToolChain - A tool chain using the llvm bitcode tools to perform
/// all subcommands. See http://tce.cs.tut.fi for our peculiar target.
class VISIBILITY_HIDDEN TCEToolChain : public ToolChain {
public:
TCEToolChain(const HostInfo &Host, const llvm::Triple& Triple);
~TCEToolChain();
virtual DerivedArgList *TranslateArgs(InputArgList &Args,
const char *BoundArch) const;
virtual Tool &SelectTool(const Compilation &C, const JobAction &JA) const;
bool IsMathErrnoDefault() const;
bool IsUnwindTablesDefault() const;
const char* GetDefaultRelocationModel() const;
const char* GetForcedPicModel() const;
private:
mutable llvm::DenseMap<unsigned, Tool*> Tools;
};
} // end namespace toolchains
} // end namespace driver
} // end namespace clang