-
Notifications
You must be signed in to change notification settings - Fork 12.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Summary: This patch enables compilation of C code for the VE target with Clang. Differential Revision: https://reviews.llvm.org/D79411
- Loading branch information
Showing
18 changed files
with
574 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
//===--- VE.cpp - Implement VE target feature support ---------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// This file implements VE TargetInfo objects. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include "VE.h" | ||
#include "clang/Basic/Builtins.h" | ||
#include "clang/Basic/MacroBuilder.h" | ||
#include "clang/Basic/TargetBuiltins.h" | ||
|
||
using namespace clang; | ||
using namespace clang::targets; | ||
|
||
void VETargetInfo::getTargetDefines(const LangOptions &Opts, | ||
MacroBuilder &Builder) const { | ||
Builder.defineMacro("_LP64", "1"); | ||
Builder.defineMacro("unix", "1"); | ||
Builder.defineMacro("__unix__", "1"); | ||
Builder.defineMacro("__linux__", "1"); | ||
Builder.defineMacro("__ve", "1"); | ||
Builder.defineMacro("__ve__", "1"); | ||
Builder.defineMacro("__STDC_HOSTED__", "1"); | ||
Builder.defineMacro("__STDC__", "1"); | ||
Builder.defineMacro("__NEC__", "1"); | ||
// FIXME: define __FAST_MATH__ 1 if -ffast-math is enabled | ||
// FIXME: define __OPTIMIZE__ n if -On is enabled | ||
// FIXME: define __VECTOR__ n 1 if automatic vectorization is enabled | ||
} | ||
|
||
ArrayRef<Builtin::Info> VETargetInfo::getTargetBuiltins() const { | ||
return ArrayRef<Builtin::Info>(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,170 @@ | ||
//===--- VE.h - Declare VE target feature support ---------------*- C++ -*-===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// This file declares VE TargetInfo objects. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef LLVM_CLANG_LIB_BASIC_TARGETS_VE_H | ||
#define LLVM_CLANG_LIB_BASIC_TARGETS_VE_H | ||
|
||
#include "clang/Basic/TargetInfo.h" | ||
#include "clang/Basic/TargetOptions.h" | ||
#include "llvm/ADT/Triple.h" | ||
#include "llvm/Support/Compiler.h" | ||
|
||
namespace clang { | ||
namespace targets { | ||
|
||
class LLVM_LIBRARY_VISIBILITY VETargetInfo : public TargetInfo { | ||
static const Builtin::Info BuiltinInfo[]; | ||
|
||
public: | ||
VETargetInfo(const llvm::Triple &Triple, const TargetOptions &) | ||
: TargetInfo(Triple) { | ||
NoAsmVariants = true; | ||
LongDoubleWidth = 128; | ||
LongDoubleAlign = 128; | ||
LongDoubleFormat = &llvm::APFloat::IEEEquad(); | ||
DoubleAlign = LongLongAlign = 64; | ||
SuitableAlign = 64; | ||
LongWidth = LongAlign = PointerWidth = PointerAlign = 64; | ||
SizeType = UnsignedLong; | ||
PtrDiffType = SignedLong; | ||
IntPtrType = SignedLong; | ||
IntMaxType = SignedLong; | ||
Int64Type = SignedLong; | ||
RegParmMax = 8; | ||
MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64; | ||
|
||
WCharType = UnsignedInt; | ||
WIntType = UnsignedInt; | ||
UseZeroLengthBitfieldAlignment = true; | ||
resetDataLayout("e-m:e-i64:64-n32:64-S64"); | ||
} | ||
|
||
void getTargetDefines(const LangOptions &Opts, | ||
MacroBuilder &Builder) const override; | ||
|
||
bool hasSjLjLowering() const override { | ||
// TODO | ||
return false; | ||
} | ||
|
||
ArrayRef<Builtin::Info> getTargetBuiltins() const override; | ||
|
||
BuiltinVaListKind getBuiltinVaListKind() const override { | ||
return TargetInfo::VoidPtrBuiltinVaList; | ||
} | ||
|
||
CallingConvCheckResult checkCallingConvention(CallingConv CC) const override { | ||
switch (CC) { | ||
default: | ||
return CCCR_Warning; | ||
case CC_C: | ||
return CCCR_OK; | ||
} | ||
} | ||
|
||
const char *getClobbers() const override { return ""; } | ||
|
||
ArrayRef<const char *> getGCCRegNames() const override { | ||
static const char *const GCCRegNames[] = { | ||
// Regular registers | ||
"sx0", "sx1", "sx2", "sx3", "sx4", "sx5", "sx6", "sx7", | ||
"sx8", "sx9", "sx10", "sx11", "sx12", "sx13", "sx14", "sx15", | ||
"sx16", "sx17", "sx18", "sx19", "sx20", "sx21", "sx22", "sx23", | ||
"sx24", "sx25", "sx26", "sx27", "sx28", "sx29", "sx30", "sx31", | ||
"sx32", "sx33", "sx34", "sx35", "sx36", "sx37", "sx38", "sx39", | ||
"sx40", "sx41", "sx42", "sx43", "sx44", "sx45", "sx46", "sx47", | ||
"sx48", "sx49", "sx50", "sx51", "sx52", "sx53", "sx54", "sx55", | ||
"sx56", "sx57", "sx58", "sx59", "sx60", "sx61", "sx62", "sx63", | ||
}; | ||
return llvm::makeArrayRef(GCCRegNames); | ||
} | ||
|
||
ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override { | ||
static const TargetInfo::GCCRegAlias GCCRegAliases[] = { | ||
{{"s0"}, "sx0"}, | ||
{{"s1"}, "sx1"}, | ||
{{"s2"}, "sx2"}, | ||
{{"s3"}, "sx3"}, | ||
{{"s4"}, "sx4"}, | ||
{{"s5"}, "sx5"}, | ||
{{"s6"}, "sx6"}, | ||
{{"s7"}, "sx7"}, | ||
{{"s8", "sl"}, "sx8"}, | ||
{{"s9", "fp"}, "sx9"}, | ||
{{"s10", "lr"}, "sx10"}, | ||
{{"s11", "sp"}, "sx11"}, | ||
{{"s12", "outer"}, "sx12"}, | ||
{{"s13"}, "sx13"}, | ||
{{"s14", "tp"}, "sx14"}, | ||
{{"s15", "got"}, "sx15"}, | ||
{{"s16", "plt"}, "sx16"}, | ||
{{"s17", "info"}, "sx17"}, | ||
{{"s18"}, "sx18"}, | ||
{{"s19"}, "sx19"}, | ||
{{"s20"}, "sx20"}, | ||
{{"s21"}, "sx21"}, | ||
{{"s22"}, "sx22"}, | ||
{{"s23"}, "sx23"}, | ||
{{"s24"}, "sx24"}, | ||
{{"s25"}, "sx25"}, | ||
{{"s26"}, "sx26"}, | ||
{{"s27"}, "sx27"}, | ||
{{"s28"}, "sx28"}, | ||
{{"s29"}, "sx29"}, | ||
{{"s30"}, "sx30"}, | ||
{{"s31"}, "sx31"}, | ||
{{"s32"}, "sx32"}, | ||
{{"s33"}, "sx33"}, | ||
{{"s34"}, "sx34"}, | ||
{{"s35"}, "sx35"}, | ||
{{"s36"}, "sx36"}, | ||
{{"s37"}, "sx37"}, | ||
{{"s38"}, "sx38"}, | ||
{{"s39"}, "sx39"}, | ||
{{"s40"}, "sx40"}, | ||
{{"s41"}, "sx41"}, | ||
{{"s42"}, "sx42"}, | ||
{{"s43"}, "sx43"}, | ||
{{"s44"}, "sx44"}, | ||
{{"s45"}, "sx45"}, | ||
{{"s46"}, "sx46"}, | ||
{{"s47"}, "sx47"}, | ||
{{"s48"}, "sx48"}, | ||
{{"s49"}, "sx49"}, | ||
{{"s50"}, "sx50"}, | ||
{{"s51"}, "sx51"}, | ||
{{"s52"}, "sx52"}, | ||
{{"s53"}, "sx53"}, | ||
{{"s54"}, "sx54"}, | ||
{{"s55"}, "sx55"}, | ||
{{"s56"}, "sx56"}, | ||
{{"s57"}, "sx57"}, | ||
{{"s58"}, "sx58"}, | ||
{{"s59"}, "sx59"}, | ||
{{"s60"}, "sx60"}, | ||
{{"s61"}, "sx61"}, | ||
{{"s62"}, "sx62"}, | ||
{{"s63"}, "sx63"}, | ||
}; | ||
return llvm::makeArrayRef(GCCRegAliases); | ||
} | ||
|
||
bool validateAsmConstraint(const char *&Name, | ||
TargetInfo::ConstraintInfo &Info) const override { | ||
return false; | ||
} | ||
|
||
bool allowsLargerPreferedTypeAlignment() const override { return false; } | ||
}; | ||
} // namespace targets | ||
} // namespace clang | ||
#endif // LLVM_CLANG_LIB_BASIC_TARGETS_VE_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
//===--- VE.cpp - Tools Implementations -------------------------*- C++ -*-===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include "VE.h" | ||
#include "clang/Driver/Driver.h" | ||
#include "clang/Driver/DriverDiagnostic.h" | ||
#include "clang/Driver/Options.h" | ||
#include "llvm/ADT/StringSwitch.h" | ||
#include "llvm/Option/ArgList.h" | ||
|
||
using namespace clang::driver; | ||
using namespace clang::driver::tools; | ||
using namespace clang; | ||
using namespace llvm::opt; | ||
|
||
const char *ve::getVEAsmModeForCPU(StringRef Name, const llvm::Triple &Triple) { | ||
return ""; | ||
} | ||
|
||
void ve::getVETargetFeatures(const Driver &D, const ArgList &Args, | ||
std::vector<StringRef> &Features) {} |
Oops, something went wrong.