StackAllocator.cs 491 B

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