#include "Basic/CodeGenIntrinsics.h"
#include "Basic/SequenceToOffsetTable.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Twine.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/FormatVariadic.h"
#include "llvm/Support/ModRef.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/TableGen/Error.h"
#include "llvm/TableGen/Record.h"
#include "llvm/TableGen/StringToOffsetTable.h"
#include "llvm/TableGen/TableGenBackend.h"
#include <algorithm>
#include <array>
#include <cassert>
#include <cctype>
#include <limits>
#include <map>
#include <optional>
#include <string>
#include <utility>
#include <vector>
usingnamespacellvm;
static cl::OptionCategory GenIntrinsicCat("Options for -gen-intrinsic-enums");
static cl::opt<std::string>
IntrinsicPrefix("intrinsic-prefix",
cl::desc("Generate intrinsics with this target prefix"),
cl::value_desc("target prefix"), cl::cat(GenIntrinsicCat));
namespace {
class IntrinsicEmitter { … };
template <bool Enums> class IntrinsicEmitterOpt : public IntrinsicEmitter { … };
}
void IntrinsicEmitter::run(raw_ostream &OS, bool Enums) { … }
void IntrinsicEmitter::EmitEnumInfo(const CodeGenIntrinsicTable &Ints,
raw_ostream &OS) { … }
void IntrinsicEmitter::EmitArgKind(raw_ostream &OS) { … }
void IntrinsicEmitter::EmitIITInfo(raw_ostream &OS) { … }
void IntrinsicEmitter::EmitTargetInfo(const CodeGenIntrinsicTable &Ints,
raw_ostream &OS) { … }
void IntrinsicEmitter::EmitIntrinsicToNameTable(
const CodeGenIntrinsicTable &Ints, raw_ostream &OS) { … }
void IntrinsicEmitter::EmitIntrinsicToOverloadTable(
const CodeGenIntrinsicTable &Ints, raw_ostream &OS) { … }
TypeSigTy;
static TypeSigTy ComputeTypeSignature(const CodeGenIntrinsic &Int) { … }
static std::optional<uint32_t> encodePacked(const TypeSigTy &TypeSig) { … }
void IntrinsicEmitter::EmitGenerator(const CodeGenIntrinsicTable &Ints,
raw_ostream &OS) { … }
static MemoryEffects getEffectiveME(const CodeGenIntrinsic &Int) { … }
static bool compareFnAttributes(const CodeGenIntrinsic *L,
const CodeGenIntrinsic *R) { … }
static bool hasFnAttributes(const CodeGenIntrinsic &Int) { … }
namespace {
struct FnAttributeComparator { … };
struct AttributeComparator { … };
}
static StringRef getArgAttrEnumName(CodeGenIntrinsic::ArgAttrKind Kind) { … }
void IntrinsicEmitter::EmitAttributes(const CodeGenIntrinsicTable &Ints,
raw_ostream &OS) { … }
void IntrinsicEmitter::EmitIntrinsicToBuiltinMap(
const CodeGenIntrinsicTable &Ints, bool IsClang, raw_ostream &OS) { … }
static TableGen::Emitter::OptClass<IntrinsicEmitterOpt<true>>
X("gen-intrinsic-enums", "Generate intrinsic enums");
static TableGen::Emitter::OptClass<IntrinsicEmitterOpt<false>>
Y("gen-intrinsic-impl", "Generate intrinsic implementation code");