Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

77 lines
2.2 KiB

  1. //===-- llvm/MC/MCValue.h - MCValue class -----------------------*- C++ -*-===//
  2. //
  3. // The LLVM Compiler Infrastructure
  4. //
  5. // This file is distributed under the University of Illinois Open Source
  6. // License. See LICENSE.TXT for details.
  7. //
  8. //===----------------------------------------------------------------------===//
  9. //
  10. // This file contains the declaration of the MCValue class.
  11. //
  12. //===----------------------------------------------------------------------===//
  13. #ifndef LLVM_MC_MCVALUE_H
  14. #define LLVM_MC_MCVALUE_H
  15. #include "llvm/MC/MCSymbol.h"
  16. #include "llvm/Support/DataTypes.h"
  17. #include <cassert>
  18. namespace llvm {
  19. class MCAsmInfo;
  20. class MCSymbol;
  21. class MCSymbolRefExpr;
  22. class raw_ostream;
  23. /// MCValue - This represents an "assembler immediate". In its most general
  24. /// form, this can hold "SymbolA - SymbolB + imm64". Not all targets supports
  25. /// relocations of this general form, but we need to represent this anyway.
  26. ///
  27. /// In the general form, SymbolB can only be defined if SymbolA is, and both
  28. /// must be in the same (non-external) section. The latter constraint is not
  29. /// enforced, since a symbol's section may not be known at construction.
  30. ///
  31. /// Note that this class must remain a simple POD value class, because we need
  32. /// it to live in unions etc.
  33. class MCValue {
  34. const MCSymbolRefExpr *SymA, *SymB;
  35. int64_t Cst;
  36. public:
  37. int64_t getConstant() const { return Cst; }
  38. const MCSymbolRefExpr *getSymA() const { return SymA; }
  39. const MCSymbolRefExpr *getSymB() const { return SymB; }
  40. /// isAbsolute - Is this an absolute (as opposed to relocatable) value.
  41. bool isAbsolute() const { return !SymA && !SymB; }
  42. /// print - Print the value to the stream \p OS.
  43. void print(raw_ostream &OS, const MCAsmInfo *MAI) const;
  44. /// dump - Print the value to stderr.
  45. void dump() const;
  46. static MCValue get(const MCSymbolRefExpr *SymA, const MCSymbolRefExpr *SymB=0,
  47. int64_t Val = 0) {
  48. MCValue R;
  49. assert((!SymB || SymA) && "Invalid relocatable MCValue!");
  50. R.Cst = Val;
  51. R.SymA = SymA;
  52. R.SymB = SymB;
  53. return R;
  54. }
  55. static MCValue get(int64_t Val) {
  56. MCValue R;
  57. R.Cst = Val;
  58. R.SymA = 0;
  59. R.SymB = 0;
  60. return R;
  61. }
  62. };
  63. } // end namespace llvm
  64. #endif