Put _start and main call into builtins

This commit is contained in:
2024-09-21 23:35:32 +02:00
parent 0a8d3fce2f
commit daec506ed3
5 changed files with 59 additions and 18 deletions

View File

@ -148,7 +148,7 @@ data RelocationType
deriving Eq
data Instruction
= Instruction BaseOpcode Type
= BaseInstruction BaseOpcode Type
| RelocatableInstruction BaseOpcode RelocationType
| CallInstruction Text
deriving Eq
@ -305,11 +305,11 @@ relocationType (Higher20 rd _) = type' $ U rd 0
instruction :: Instruction -> ByteString.Builder.Builder
instruction = \case
(Instruction base instructionType) -> go base $ type' instructionType
(BaseInstruction base instructionType) -> go base $ type' instructionType
(RelocatableInstruction base instructionType) -> go base $ relocationType instructionType
(CallInstruction _) -> foldMap instruction
[ Instruction Auipc $ U RA 0
, Instruction Jalr $ I RA JALR RA 0
[ BaseInstruction Auipc $ U RA 0
, BaseInstruction Jalr $ I RA JALR RA 0
]
where
go base instructionType