
This commit adds support for LLVM 16 and switches to it by default. That means three LLVM versions are supported at the same time: LLVM 14, 15, and 16. This commit includes work by QuLogic: * Part of this work was based on a PR by QuLogic: https://github.com/tinygo-org/tinygo/pull/3649 But I also had parts of this already implemented in an old branch I already made for LLVM 16. * QuLogic also provided a CGo fix here, which is also incorporated in this commit: https://github.com/tinygo-org/tinygo/pull/3869 The difference with the original PR by QuLogic is that this commit is more complete: * It switches to LLVM 16 by default. * It updates some things to also make it work with a self-built LLVM. * It fixes the CGo bug in a slightly different way, and also fixes another one not included in the original PR. * It does not keep compiler tests passing on older LLVM versions. I have found this to be quite burdensome and therefore don't generally do this - the smoke tests should hopefully catch most regressions.
138 строки
3,9 КиБ
C++
138 строки
3,9 КиБ
C++
//===-- cc1as.h - Clang Assembler ----------------------------------------===//
|
|
//
|
|
// 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 is the entry point to the clang -cc1as functionality, which implements
|
|
// the direct interface to the LLVM MC based assembler.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
/// Helper class for representing a single invocation of the assembler.
|
|
struct AssemblerInvocation {
|
|
/// @name Target Options
|
|
/// @{
|
|
|
|
/// The name of the target triple to assemble for.
|
|
std::string Triple;
|
|
|
|
/// If given, the name of the target CPU to determine which instructions
|
|
/// are legal.
|
|
std::string CPU;
|
|
|
|
/// The list of target specific features to enable or disable -- this should
|
|
/// be a list of strings starting with '+' or '-'.
|
|
std::vector<std::string> Features;
|
|
|
|
/// The list of symbol definitions.
|
|
std::vector<std::string> SymbolDefs;
|
|
|
|
/// @}
|
|
/// @name Language Options
|
|
/// @{
|
|
|
|
std::vector<std::string> IncludePaths;
|
|
unsigned NoInitialTextSection : 1;
|
|
unsigned SaveTemporaryLabels : 1;
|
|
unsigned GenDwarfForAssembly : 1;
|
|
unsigned RelaxELFRelocations : 1;
|
|
unsigned Dwarf64 : 1;
|
|
unsigned DwarfVersion;
|
|
std::string DwarfDebugFlags;
|
|
std::string DwarfDebugProducer;
|
|
std::string DebugCompilationDir;
|
|
std::map<const std::string, const std::string> DebugPrefixMap;
|
|
llvm::DebugCompressionType CompressDebugSections =
|
|
llvm::DebugCompressionType::None;
|
|
std::string MainFileName;
|
|
std::string SplitDwarfOutput;
|
|
|
|
/// @}
|
|
/// @name Frontend Options
|
|
/// @{
|
|
|
|
std::string InputFile;
|
|
std::vector<std::string> LLVMArgs;
|
|
std::string OutputPath;
|
|
enum FileType {
|
|
FT_Asm, ///< Assembly (.s) output, transliterate mode.
|
|
FT_Null, ///< No output, for timing purposes.
|
|
FT_Obj ///< Object file output.
|
|
};
|
|
FileType OutputType;
|
|
unsigned ShowHelp : 1;
|
|
unsigned ShowVersion : 1;
|
|
|
|
/// @}
|
|
/// @name Transliterate Options
|
|
/// @{
|
|
|
|
unsigned OutputAsmVariant;
|
|
unsigned ShowEncoding : 1;
|
|
unsigned ShowInst : 1;
|
|
|
|
/// @}
|
|
/// @name Assembler Options
|
|
/// @{
|
|
|
|
unsigned RelaxAll : 1;
|
|
unsigned NoExecStack : 1;
|
|
unsigned FatalWarnings : 1;
|
|
unsigned NoWarn : 1;
|
|
unsigned NoTypeCheck : 1;
|
|
unsigned IncrementalLinkerCompatible : 1;
|
|
unsigned EmbedBitcode : 1;
|
|
|
|
/// Whether to emit DWARF unwind info.
|
|
EmitDwarfUnwindType EmitDwarfUnwind;
|
|
|
|
/// The name of the relocation model to use.
|
|
std::string RelocationModel;
|
|
|
|
/// The ABI targeted by the backend. Specified using -target-abi. Empty
|
|
/// otherwise.
|
|
std::string TargetABI;
|
|
|
|
/// Darwin target variant triple, the variant of the deployment target
|
|
/// for which the code is being compiled.
|
|
std::optional<llvm::Triple> DarwinTargetVariantTriple;
|
|
|
|
/// The version of the darwin target variant SDK which was used during the
|
|
/// compilation
|
|
llvm::VersionTuple DarwinTargetVariantSDKVersion;
|
|
|
|
/// The name of a file to use with \c .secure_log_unique directives.
|
|
std::string AsSecureLogFile;
|
|
/// @}
|
|
|
|
public:
|
|
AssemblerInvocation() {
|
|
Triple = "";
|
|
NoInitialTextSection = 0;
|
|
InputFile = "-";
|
|
OutputPath = "-";
|
|
OutputType = FT_Asm;
|
|
OutputAsmVariant = 0;
|
|
ShowInst = 0;
|
|
ShowEncoding = 0;
|
|
RelaxAll = 0;
|
|
NoExecStack = 0;
|
|
FatalWarnings = 0;
|
|
NoWarn = 0;
|
|
NoTypeCheck = 0;
|
|
IncrementalLinkerCompatible = 0;
|
|
Dwarf64 = 0;
|
|
DwarfVersion = 0;
|
|
EmbedBitcode = 0;
|
|
EmitDwarfUnwind = EmitDwarfUnwindType::Default;
|
|
}
|
|
|
|
static bool CreateFromArgs(AssemblerInvocation &Res,
|
|
ArrayRef<const char *> Argv,
|
|
DiagnosticsEngine &Diags);
|
|
};
|
|
|
|
bool ExecuteAssembler(AssemblerInvocation &Opts, DiagnosticsEngine &Diags);
|