}
};
-// Inline Assembly Node
-class InlineAsm : public ExprWithoutBlock
+// Inline-assembly specific options
+enum class InlineAsmOptions
+{
+ PURE = 1 << 0,
+ NOMEM = 1 << 1,
+ READONLY = 1 << 2,
+ PRESERVES_FLAGS = 1 << 3,
+ NORETURN = 1 << 4,
+ NOSTACK = 1 << 5,
+ ATT_SYNTAX = 1 << 6,
+ RAW = 1 << 7,
+ MAY_UNWIND = 1 << 8,
+};
+
+struct AnonConst
{
- // Inline-assembly specific options
- enum InlineAsmOptions
- {
- PURE = 1 << 0,
- NOMEM = 1 << 1,
- READONLY = 1 << 2,
- PRESERVES_FLAGS = 1 << 3,
- NORETURN = 1 << 4,
- NOSTACK = 1 << 5,
- ATT_SYNTAX = 1 << 6,
- RAW = 1 << 7,
- MAY_UNWIND = 1 << 8,
+ NodeId id;
+ std::unique_ptr<Expr> value;
+};
+
+struct InlineAsmRegOrRegClass
+{
+ enum Type
+ {
+ Reg,
+ RegClass,
};
- struct AnonConst
+ struct Reg
{
- NodeId id;
- std::unique_ptr<Expr> value;
+ std::string Symbol;
};
- struct InlineAsmRegOrRegClass
+ struct RegClass
{
- enum Type
- {
- Reg,
- RegClass,
- };
+ std::string Symbol;
+ };
- struct Reg
- {
- std::string Symbol;
- };
+ Identifier name;
+ Location locus;
+};
- struct RegClass
- {
- std::string Symbol;
- };
+struct InlineAsmOperand
+{
+ enum RegisterType
+ {
+ In,
+ Out,
+ InOut,
+ SplitInOut,
+ Const,
+ Sym,
+ };
- Identifier name;
- Location locus;
+ struct In
+ {
+ InlineAsmRegOrRegClass reg;
+ std::unique_ptr<Expr> expr;
+ };
+
+ struct Out
+ {
+ InlineAsmRegOrRegClass reg;
+ bool late;
+ std::unique_ptr<Expr> expr; // can be null
};
- struct InlineAsmOperand
- {
- enum RegisterType
- {
- In,
- Out,
- InOut,
- SplitInOut,
- Const,
- Sym,
- };
-
- struct In
- {
- InlineAsmRegOrRegClass reg;
- std::unique_ptr<Expr> expr;
- };
-
- struct Out
- {
- InlineAsmRegOrRegClass reg;
- bool late;
- std::unique_ptr<Expr> expr; // can be null
- };
-
- struct InOut
- {
- InlineAsmRegOrRegClass reg;
- bool late;
- std::unique_ptr<Expr> expr; // this can't be null
- };
-
- struct SplitInOut
- {
- InlineAsmRegOrRegClass reg;
- bool late;
- std::unique_ptr<Expr> in_expr;
- std::unique_ptr<Expr> out_expr; // could be null
- };
-
- struct Const
- {
- AnonConst anon_const;
- };
-
- struct Sym
- {
- std::unique_ptr<Expr> sym;
- };
- Location locus;
+ struct InOut
+ {
+ InlineAsmRegOrRegClass reg;
+ bool late;
+ std::unique_ptr<Expr> expr; // this can't be null
};
- struct InlineAsmPlaceHolder
+ struct SplitInOut
{
- size_t operand_idx;
- char modifier; // can be null
- Location locus;
+ InlineAsmRegOrRegClass reg;
+ bool late;
+ std::unique_ptr<Expr> in_expr;
+ std::unique_ptr<Expr> out_expr; // could be null
};
- struct InlineAsmTemplatePiece
+ struct Const
{
- bool is_placeholder;
- union
- {
- std::string string;
- InlineAsmPlaceHolder placeholder;
- };
+ AnonConst anon_const;
};
- struct TupleClobber
+ struct Sym
{
- // as gccrs still doesen't contain a symbol class I have put them as strings
- std::string symbol;
- Location loc;
+ std::unique_ptr<Expr> sym;
};
+ Location locus;
+};
+
+struct InlineAsmPlaceHolder
+{
+ size_t operand_idx;
+ char modifier; // can be null
+ Location locus;
+};
- struct TupleTemplateStr
+struct InlineAsmTemplatePiece
+{
+ bool is_placeholder;
+ union
{
- // as gccrs still doesen't contain a symbol class I have put them as strings
- std::string symbol;
- std::string optional_symbol;
- Location loc;
+ std::string string;
+ InlineAsmPlaceHolder placeholder;
};
+};
+struct TupleClobber
+{
+ // as gccrs still doesen't contain a symbol class I have put them as strings
+ std::string symbol;
+ Location loc;
+};
+
+struct TupleTemplateStr
+{
+ // as gccrs still doesen't contain a symbol class I have put them as strings
+ std::string symbol;
+ std::string optional_symbol;
+ Location loc;
+};
+
+// Inline Assembly Node
+class InlineAsm : public ExprWithoutBlock
+{
public:
std::vector<InlineAsmTemplatePiece> template_;
std::vector<TupleTemplateStr> template_strs;
InlineAsmOptions options;
std::vector<Location> line_spans;
};
+
} // namespace AST
} // namespace Rust
Location locus;
};
+class InlineAsmReg
+{
+ enum Kind
+ {
+ X86,
+ Arm,
+ AArch64,
+ RiscV,
+ Nvptx,
+ PowerPC,
+ Hexagon,
+ Mips,
+ S390x,
+ SpirV,
+ Wasm,
+ Bpf,
+ Avr,
+ Msp430,
+ // Placeholder for invalid register constraints for the current target
+ Err,
+ };
+
+ // this placeholder is to be removed when the definations
+ // of the above enums are made in a later PR/patch.
+ std::string placeholder;
+};
+
+class InlineAsmRegClass
+{
+ enum Type
+ {
+ X86,
+ Arm,
+ AArch64,
+ RiscV,
+ Nvptx,
+ PowerPC,
+ Hexagon,
+ Mips,
+ S390x,
+ SpirV,
+ Wasm,
+ Bpf,
+ Avr,
+ Msp430,
+ // Placeholder for invalid register constraints for the current target
+ Err,
+ };
+
+ // this placeholder is to be removed when the definations
+ // of the above enums are made in a later PR/patch.
+ std::string placeholder;
+};
+
+struct InlineAsmRegOrRegClass
+{
+ enum Type
+ {
+ Reg, // links to struct Register
+ RegClass, // links to struct RegisterClass
+ };
+
+ struct Register
+ {
+ InlineAsmReg Reg;
+ };
+
+ struct RegisterClass
+ {
+ InlineAsmRegClass RegClass;
+ };
+
+ Identifier name;
+ Location locus;
+};
+
+// Inline Assembly Node
+class InlineAsm : public ExprWithoutBlock
+{
+ NodeId id;
+
+public:
+ std::vector<AST::InlineAsmTemplatePiece> template_;
+ std::vector<AST::TupleTemplateStr> template_strs;
+ std::vector<AST::InlineAsmOperand> operands;
+ AST::InlineAsmOptions options;
+ std::vector<Location> line_spans;
+};
} // namespace HIR
} // namespace Rust