Skip to content

Commit

Permalink
POWER: refactor ?load evaluators
Browse files Browse the repository at this point in the history
...to use common helper.
  • Loading branch information
janvrany authored and shingarov committed Nov 28, 2023
1 parent 7b8ec78 commit 3aa53ea
Showing 1 changed file with 46 additions and 6 deletions.
52 changes: 46 additions & 6 deletions src/Tinyrossa-POWER/TRPPC64CodeEvaluator.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,57 @@ Class {
#name : #TRPPC64CodeEvaluator,
#superclass : #TRCodeEvaluator,
#pools : [
'TRDataTypes',
'TRPPC64RegisterKinds',
'TRPPC64Registers'
],
#category : #'Tinyrossa-POWER-Codegen'
}

{ #category : #'evaluation-helpers' }
TRPPC64CodeEvaluator >> commonLoad: node [
"Handles aload, lload, iload, sload & bload"

| dstReg offset type |

offset := (AcDSLSymbol value: node symbol name).
dstReg := codegen allocateRegister.

type := node type.
(type == Address or:[type == Int64]) ifTrue:[
self shouldImplement
] ifFalse:[ type == Int32 ifTrue:[
generate
lwz: dstReg, (gr1 + offset).
] ifFalse:[ type == Int16 ifTrue:[
self shouldImplement
] ifFalse:[ type == Int8 ifTrue:[
self shouldImplement
]]]].

^dstReg.
]

{ #category : #evaluation }
TRPPC64CodeEvaluator >> evaluate_aconst: node [
^self evaluate_lconst: node
]

{ #category : #evaluation }
TRPPC64CodeEvaluator >> evaluate_aload: node [
^ self commonLoad: node
]

{ #category : #evaluation }
TRPPC64CodeEvaluator >> evaluate_bconst: node [
^ self evaluate_iconst: node
]

{ #category : #evaluation }
TRPPC64CodeEvaluator >> evaluate_bload: node [
^ self commonLoad: node
]

{ #category : #evaluation }
TRPPC64CodeEvaluator >> evaluate_goto: node [
generate b: node symbol.
Expand Down Expand Up @@ -132,12 +167,7 @@ TRPPC64CodeEvaluator >> evaluate_ificmpne: node [

{ #category : #evaluation }
TRPPC64CodeEvaluator >> evaluate_iload: node [
| symbol dstReg |

symbol := node symbol.
dstReg := codegen allocateRegister.
generate lwz: dstReg, (gr1 + (AcDSLSymbol value: symbol name)).
^ dstReg
^ self commonLoad: node
]

{ #category : #evaluation }
Expand Down Expand Up @@ -194,7 +224,17 @@ TRPPC64CodeEvaluator >> evaluate_lconst: node [
^ dstReg
]

{ #category : #evaluation }
TRPPC64CodeEvaluator >> evaluate_lload: node [
^ self commonLoad: node
]

{ #category : #evaluation }
TRPPC64CodeEvaluator >> evaluate_sconst: node [
^ self evaluate_iconst: node
]

{ #category : #evaluation }
TRPPC64CodeEvaluator >> evaluate_sload: node [
^ self commonLoad: node
]

0 comments on commit 3aa53ea

Please sign in to comment.