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.

68 lines
1.7 KiB

  1. //===-- llvm/MC/MCInstBuilder.h - Simplify creation of MCInsts --*- 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 MCInstBuilder class for convenient creation of
  11. // MCInsts.
  12. //
  13. //===----------------------------------------------------------------------===//
  14. #ifndef LLVM_MC_MCINSTBUILDER_H
  15. #define LLVM_MC_MCINSTBUILDER_H
  16. #include "llvm/MC/MCInst.h"
  17. namespace llvm {
  18. class MCInstBuilder {
  19. MCInst Inst;
  20. public:
  21. /// \brief Create a new MCInstBuilder for an MCInst with a specific opcode.
  22. MCInstBuilder(unsigned Opcode) {
  23. Inst.setOpcode(Opcode);
  24. }
  25. /// \brief Add a new register operand.
  26. MCInstBuilder &addReg(unsigned Reg) {
  27. Inst.addOperand(MCOperand::CreateReg(Reg));
  28. return *this;
  29. }
  30. /// \brief Add a new integer immediate operand.
  31. MCInstBuilder &addImm(int64_t Val) {
  32. Inst.addOperand(MCOperand::CreateImm(Val));
  33. return *this;
  34. }
  35. /// \brief Add a new floating point immediate operand.
  36. MCInstBuilder &addFPImm(double Val) {
  37. Inst.addOperand(MCOperand::CreateFPImm(Val));
  38. return *this;
  39. }
  40. /// \brief Add a new MCExpr operand.
  41. MCInstBuilder &addExpr(const MCExpr *Val) {
  42. Inst.addOperand(MCOperand::CreateExpr(Val));
  43. return *this;
  44. }
  45. /// \brief Add a new MCInst operand.
  46. MCInstBuilder &addInst(const MCInst *Val) {
  47. Inst.addOperand(MCOperand::CreateInst(Val));
  48. return *this;
  49. }
  50. operator MCInst&() {
  51. return Inst;
  52. }
  53. };
  54. } // end namespace llvm
  55. #endif