summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tools/llvm-mc/AsmExpr.h68
1 files changed, 41 insertions, 27 deletions
diff --git a/tools/llvm-mc/AsmExpr.h b/tools/llvm-mc/AsmExpr.h
index e8650e468f..84e58ffd9b 100644
--- a/tools/llvm-mc/AsmExpr.h
+++ b/tools/llvm-mc/AsmExpr.h
@@ -18,13 +18,15 @@ class MCContext;
class MCSymbol;
class MCValue;
+/// AsmExpr - Base class for the full range of assembler expressions which are
+/// needed for parsing.
class AsmExpr {
public:
enum AsmExprKind {
- Binary, /// Binary expressions.
- Constant, /// Constant expressions.
- SymbolRef, /// References to labels and assigned expressions.
- Unary /// Unary expressions.
+ Binary, ///< Binary expressions.
+ Constant, ///< Constant expressions.
+ SymbolRef, ///< References to labels and assigned expressions.
+ Unary ///< Unary expressions.
};
private:
@@ -45,7 +47,7 @@ public:
bool EvaluateAsAbsolute(MCContext &Ctx, int64_t &Res) const;
/// EvaluateAsRelocatable - Try to evaluate the expression to a relocatable
- /// value.
+ /// value, i.e. an expression of the fixed form (a - b + constant).
///
/// @param Res - The relocatable value, if evaluation succeeds.
/// @result - True on success.
@@ -54,6 +56,7 @@ public:
static bool classof(const AsmExpr *) { return true; }
};
+//// AsmConstantExpr - Represent a constant integer expression.
class AsmConstantExpr : public AsmExpr {
int64_t Value;
@@ -69,6 +72,12 @@ public:
static bool classof(const AsmConstantExpr *) { return true; }
};
+/// AsmSymbolRefExpr - Represent a reference to a symbol from inside an
+/// expression.
+///
+/// A symbol reference in an expression may be a use of a label, a use of an
+/// assembler variable (defined constant), or constitute an implicit definition
+/// of the symbol as external.
class AsmSymbolRefExpr : public AsmExpr {
MCSymbol *Symbol;
@@ -84,13 +93,14 @@ public:
static bool classof(const AsmSymbolRefExpr *) { return true; }
};
+/// AsmUnaryExpr - Unary assembler expressions.
class AsmUnaryExpr : public AsmExpr {
public:
enum Opcode {
- LNot, /// Logical negation.
- Minus, /// Unary minus.
- Not, /// Bit-wise negation.
- Plus /// Unary plus.
+ LNot, ///< Logical negation.
+ Minus, ///< Unary minus.
+ Not, ///< Bitwise negation.
+ Plus ///< Unary plus.
};
private:
@@ -114,27 +124,28 @@ public:
static bool classof(const AsmUnaryExpr *) { return true; }
};
+/// AsmBinaryExpr - Binary assembler expressions.
class AsmBinaryExpr : public AsmExpr {
public:
enum Opcode {
- Add, /// Addition.
- And, /// Bitwise and.
- Div, /// Division.
- EQ, /// Equality comparison.
- GT, /// Greater than comparison.
- GTE, /// Greater than or equal comparison.
- LAnd, /// Logical and.
- LOr, /// Logical or.
- LT, /// Less than comparison.
- LTE, /// Less than or equal comparison.
- Mod, /// Modulus.
- Mul, /// Multiplication.
- NE, /// Inequality comparison.
- Or, /// Bitwise or.
- Shl, /// Bitwise shift left.
- Shr, /// Bitwise shift right.
- Sub, /// Subtraction.
- Xor /// Bitwise exclusive or.
+ Add, ///< Addition.
+ And, ///< Bitwise and.
+ Div, ///< Division.
+ EQ, ///< Equality comparison.
+ GT, ///< Greater than comparison.
+ GTE, ///< Greater than or equal comparison.
+ LAnd, ///< Logical and.
+ LOr, ///< Logical or.
+ LT, ///< Less than comparison.
+ LTE, ///< Less than or equal comparison.
+ Mod, ///< Modulus.
+ Mul, ///< Multiplication.
+ NE, ///< Inequality comparison.
+ Or, ///< Bitwise or.
+ Shl, ///< Bitwise shift left.
+ Shr, ///< Bitwise shift right.
+ Sub, ///< Subtraction.
+ Xor ///< Bitwise exclusive or.
};
private:
@@ -151,7 +162,10 @@ public:
Opcode getOpcode() const { return Op; }
+ /// getLHS - Get the left-hand side expression of the binary operator.
AsmExpr *getLHS() const { return LHS; }
+
+ /// getRHS - Get the right-hand side expression of the binary operator.
AsmExpr *getRHS() const { return RHS; }
static bool classof(const AsmExpr *E) {