36class ExpressionGenerator :
public Generator {
38 virtual ~ExpressionGenerator() =
default;
39 explicit ExpressionGenerator(
const SmithTarget &target) : Generator(target) {}
41 static constexpr size_t MAX_DEPTH = 3;
43 static constexpr int BIT_WIDTHS[6] = {4, 8, 16, 32, 64, 128};
45 static const IR::Type_Boolean *genBoolType();
47 static const IR::Type_InfInt *genIntType();
50 static const IR::Type_Bits *genBitType(
bool isSigned);
52 static const IR::Type *pickRndBaseType(
const std::vector<int64_t> &type_probs);
54 virtual const IR::Type *pickRndType(TyperefProbs type_probs);
56 static IR::BoolLiteral *genBoolLiteral();
58 static IR::Constant *genIntLiteral(
size_t bit_width = INTEGER_WIDTH);
60 static IR::Constant *genBitLiteral(
const IR::Type *tb);
63 IR::Expression *constructUnaryExpr(
const IR::Type_Bits *tb);
65 IR::Expression *createSaturationOperand(
const IR::Type_Bits *tb);
67 IR::Expression *constructBinaryBitExpr(
const IR::Type_Bits *tb);
69 IR::Expression *constructTernaryBitExpr(
const IR::Type_Bits *tb);
72 virtual IR::Expression *pickBitVar(
const IR::Type_Bits *tb);
74 virtual IR::Expression *constructBitExpr(
const IR::Type_Bits *tb);
77 IR::Expression *constructCmpExpr();
80 virtual IR::Expression *constructBooleanExpr();
83 IR::Expression *constructUnaryIntExpr();
85 IR::Expression *constructBinaryIntExpr();
87 static IR::Expression *pickIntVar();
90 IR::Expression *constructIntExpr();
93 IR::ListExpression *genStructListExpr(
const IR::Type_Name *tn);
95 IR::Expression *editHdrStack(
cstring lval);
98 virtual IR::Expression *constructStructExpr(
const IR::Type_Name *tn);
100 virtual IR::MethodCallExpression *genFunctionCall(
cstring method_name,
101 IR::ParameterList params);
103 virtual IR::MethodCallExpression *pickFunction(
106 virtual IR::Expression *genExpression(
const IR::Type *tp);
110 virtual IR::Expression *genInputArg(
const IR::Parameter *param);
112 virtual IR::Expression *pickLvalOrSlice(
const IR::Type *tp);
114 virtual bool checkInputArg(
const IR::Parameter *param);