pools.go 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. //
  2. // Copyright 2024 CloudWeGo Authors
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. //
  8. // http://www.apache.org/licenses/LICENSE-2.0
  9. //
  10. // Unless required by applicable law or agreed to in writing, software
  11. // distributed under the License is distributed on an "AS IS" BASIS,
  12. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. // See the License for the specific language governing permissions and
  14. // limitations under the License.
  15. //
  16. package x86_64
  17. // CreateLabel creates a new Label, it may allocate a new one or grab one from a pool.
  18. func CreateLabel(name string) *Label {
  19. p := new(Label)
  20. /* initialize the label */
  21. p.refs = 1
  22. p.Name = name
  23. return p
  24. }
  25. func newProgram(arch *Arch) *Program {
  26. p := new(Program)
  27. /* initialize the program */
  28. p.arch = arch
  29. return p
  30. }
  31. func newInstruction(name string, argc int, argv Operands) *Instruction {
  32. p := new(Instruction)
  33. /* initialize the instruction */
  34. p.name = name
  35. p.argc = argc
  36. p.argv = argv
  37. return p
  38. }
  39. // CreateMemoryOperand creates a new MemoryOperand, it may allocate a new one or grab one from a pool.
  40. func CreateMemoryOperand() *MemoryOperand {
  41. p := new(MemoryOperand)
  42. /* initialize the memory operand */
  43. p.refs = 1
  44. return p
  45. }