StackAllocator.cs 531 B

123456789101112131415161718192021222324252627
  1. using ARMeilleure.Common;
  2. using ARMeilleure.IntermediateRepresentation;
  3. using System;
  4. namespace ARMeilleure.CodeGen.RegisterAllocators
  5. {
  6. class StackAllocator
  7. {
  8. private int _offset;
  9. public int TotalSize => _offset;
  10. public int Allocate(OperandType type)
  11. {
  12. return Allocate(type.GetSizeInBytes());
  13. }
  14. public int Allocate(int sizeInBytes)
  15. {
  16. int offset = _offset;
  17. _offset += sizeInBytes;
  18. return offset;
  19. }
  20. }
  21. }