54class ExpressionGenerator :
public Generator {
56 virtual ~ExpressionGenerator() =
default;
57 explicit ExpressionGenerator(
const SmithTarget &target) : Generator(target) {}
59 static constexpr size_t MAX_DEPTH = 3;
61 static const IR::Type_Boolean *genBoolType();
63 static const IR::Type_InfInt *genIntType();
66 [[nodiscard]]
const IR::Type_Bits *genBitType(
bool isSigned)
const;
67 [[nodiscard]]
const IR::Type *pickRndBaseType(
const std::vector<int64_t> &type_probs)
const;
69 [[nodiscard]]
virtual const IR::Type *pickRndType(TyperefProbs type_probs);
71 static IR::BoolLiteral *genBoolLiteral();
73 static IR::Constant *genIntLiteral(
size_t bit_width = INTEGER_WIDTH);
75 static IR::Constant *genBitLiteral(
const IR::Type *tb);
77 [[nodiscard]]
virtual std::vector<int> availableBitWidths()
const {
78 return {4, 8, 16, 32, 64, 128};
82 IR::Expression *constructUnaryExpr(
const IR::Type_Bits *tb);
84 IR::Expression *createSaturationOperand(
const IR::Type_Bits *tb);
86 IR::Expression *constructBinaryBitExpr(
const IR::Type_Bits *tb);
88 IR::Expression *constructTernaryBitExpr(
const IR::Type_Bits *tb);
91 virtual IR::Expression *pickBitVar(
const IR::Type_Bits *tb);
93 virtual IR::Expression *constructBitExpr(
const IR::Type_Bits *tb);
96 IR::Expression *constructCmpExpr();
99 virtual IR::Expression *constructBooleanExpr();
102 IR::Expression *constructUnaryIntExpr();
104 IR::Expression *constructBinaryIntExpr();
106 static IR::Expression *pickIntVar();
109 IR::Expression *constructIntExpr();
112 IR::ListExpression *genStructListExpr(
const IR::Type_Name *tn);
114 IR::Expression *editHdrStack(
cstring lval);
117 virtual IR::Expression *constructStructExpr(
const IR::Type_Name *tn);
119 virtual IR::MethodCallExpression *genFunctionCall(
cstring method_name,
120 IR::ParameterList params);
122 virtual IR::MethodCallExpression *pickFunction(
125 virtual IR::Expression *genExpression(
const IR::Type *tp);
129 virtual IR::Expression *genInputArg(
const IR::Parameter *param);
131 virtual IR::Expression *pickLvalOrSlice(
const IR::Type *tp);
133 virtual bool checkInputArg(
const IR::Parameter *param);