mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-11-03 07:54:40 +08:00
53 lines
1.9 KiB
C++
53 lines
1.9 KiB
C++
#pragma once
|
|
|
|
#include "llvm/ADT/StringRef.h"
|
|
#include "llvm/Support/CodeGen.h"
|
|
#include "llvm/Target/TargetOptions.h"
|
|
|
|
#include <memory>
|
|
#include <string>
|
|
|
|
namespace llvm {
|
|
class TargetMachine;
|
|
class Triple;
|
|
} // namespace llvm
|
|
|
|
namespace scriptc {
|
|
|
|
inline constexpr llvm::StringLiteral ProtocolVersion = "1";
|
|
inline constexpr llvm::StringLiteral LlvmVersion = "22.1.8";
|
|
#ifndef SCRIPTC_DEFAULT_TARGET
|
|
#define SCRIPTC_DEFAULT_TARGET "arm64-apple-macosx14.0.0"
|
|
#endif
|
|
#ifndef SCRIPTC_DEFAULT_DATA_LAYOUT
|
|
#define SCRIPTC_DEFAULT_DATA_LAYOUT "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-n32:64-S128-Fn32"
|
|
#endif
|
|
#ifndef SCRIPTC_TARGET_BACKENDS
|
|
#define SCRIPTC_TARGET_BACKENDS "AArch64"
|
|
#endif
|
|
#ifndef SCRIPTC_ALLOWED_TARGETS
|
|
#define SCRIPTC_ALLOWED_TARGETS "arm64-apple-macosx14.0.0"
|
|
#endif
|
|
inline constexpr llvm::StringLiteral DefaultTarget =
|
|
SCRIPTC_DEFAULT_TARGET;
|
|
inline constexpr llvm::StringLiteral DefaultDataLayout =
|
|
SCRIPTC_DEFAULT_DATA_LAYOUT;
|
|
inline constexpr llvm::StringLiteral TargetBackends = SCRIPTC_TARGET_BACKENDS;
|
|
inline constexpr llvm::StringLiteral AllowedTargets = SCRIPTC_ALLOWED_TARGETS;
|
|
|
|
void initializeTargets();
|
|
bool supportsTarget(llvm::StringRef Triple);
|
|
// The target options and code generation level every helper target machine
|
|
// uses, shared with the partitioned optimizer's configuration.
|
|
llvm::TargetOptions targetOptions(const llvm::Triple &TargetTriple);
|
|
// Lays out code by a profile's context-sensitive counts from now on: one
|
|
// section per function, and cold blocks split into .text.split sections.
|
|
// ELF targets only; the helper calls it once, before any target machine.
|
|
void enableProfileLayout();
|
|
llvm::CodeGenOptLevel codeGenLevel(llvm::StringRef OptLevel);
|
|
std::unique_ptr<llvm::TargetMachine>
|
|
createTargetMachine(llvm::StringRef Triple, llvm::StringRef OptLevel,
|
|
std::string &Error, bool RequireAllowed = true);
|
|
|
|
} // namespace scriptc
|