#include "llvm/ADT/APFloat.h"
#include "llvm/ADT/APInt.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Twine.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/CallingConv.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/GlobalValue.h"
#include "llvm/IR/InstrTypes.h"
#include "llvm/IR/Instruction.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/Type.h"
#include "llvm/IR/Value.h"
#include "llvm/IR/Verifier.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/InitLLVM.h"
#include "llvm/Support/ToolOutputFile.h"
#include "llvm/Support/WithColor.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
#include <cassert>
#include <cstddef>
#include <cstdint>
#include <memory>
#include <string>
#include <system_error>
#include <vector>
namespace llvm {
static cl::OptionCategory StressCategory("Stress Options");
static cl::opt<unsigned> SeedCL("seed", cl::desc("Seed used for randomness"),
cl::init(0), cl::cat(StressCategory));
static cl::opt<unsigned> SizeCL(
"size",
cl::desc("The estimated size of the generated function (# of instrs)"),
cl::init(100), cl::cat(StressCategory));
static cl::opt<std::string> OutputFilename("o",
cl::desc("Override output filename"),
cl::value_desc("filename"),
cl::cat(StressCategory));
static cl::list<StringRef> AdditionalScalarTypes(
"types", cl::CommaSeparated,
cl::desc("Additional IR scalar types "
"(always includes i1, i8, i16, i32, i64, float and double)"));
static cl::opt<bool> EnableScalableVectors(
"enable-scalable-vectors",
cl::desc("Generate IR involving scalable vector types"),
cl::init(false), cl::cat(StressCategory));
namespace {
class Random { … };
Function *GenEmptyFunction(Module *M) { … }
struct Modifier { … };
struct LoadModifier: public Modifier { … };
struct StoreModifier: public Modifier { … };
struct BinModifier: public Modifier { … };
struct ConstModifier: public Modifier { … };
struct AllocaModifier: public Modifier { … };
struct ExtractElementModifier: public Modifier { … };
struct ShuffModifier: public Modifier { … };
struct InsertElementModifier: public Modifier { … };
struct CastModifier: public Modifier { … };
struct SelectModifier: public Modifier { … };
struct CmpModifier: public Modifier { … };
}
static void FillFunction(Function *F, Random &R) { … }
static void IntroduceControlFlow(Function *F, Random &R) { … }
}
int main(int argc, char **argv) { … }