style: fix style
This commit is contained in:
parent
02e741c52e
commit
ee4109e9cd
@ -30,11 +30,16 @@ object asmGenerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//TODO
|
//TODO
|
||||||
def generateFuncs()(using stack: LinkedHashMap[Ident, Int], strings: ListBuffer[String]): List[AsmLine] = {
|
def generateFuncs()(using
|
||||||
|
stack: LinkedHashMap[Ident, Int],
|
||||||
|
strings: ListBuffer[String]
|
||||||
|
): List[AsmLine] = {
|
||||||
List()
|
List()
|
||||||
}
|
}
|
||||||
|
|
||||||
def generateStmt(stmt: Stmt)(using stack: LinkedHashMap[Ident, Int], strings: ListBuffer[String]): List[AsmLine] =
|
def generateStmt(
|
||||||
|
stmt: Stmt
|
||||||
|
)(using stack: LinkedHashMap[Ident, Int], strings: ListBuffer[String]): List[AsmLine] =
|
||||||
stmt match {
|
stmt match {
|
||||||
case microWacc.Call(Builtin.Exit, code :: _) =>
|
case microWacc.Call(Builtin.Exit, code :: _) =>
|
||||||
alignStack() ++
|
alignStack() ++
|
||||||
@ -47,7 +52,8 @@ object asmGenerator {
|
|||||||
List(
|
List(
|
||||||
assemblyIR.Call(CLibFunc.Puts),
|
assemblyIR.Call(CLibFunc.Puts),
|
||||||
Move(Register(RegSize.R64, RegName.DI), ImmediateVal(0)),
|
Move(Register(RegSize.R64, RegName.DI), ImmediateVal(0)),
|
||||||
assemblyIR.Call(CLibFunc.Fflush)) ++
|
assemblyIR.Call(CLibFunc.Fflush)
|
||||||
|
) ++
|
||||||
restoreStack()
|
restoreStack()
|
||||||
|
|
||||||
case microWacc.Call(Builtin.ReadInt, expr :: _) =>
|
case microWacc.Call(Builtin.ReadInt, expr :: _) =>
|
||||||
@ -64,8 +70,10 @@ object asmGenerator {
|
|||||||
case _ => List()
|
case _ => List()
|
||||||
}
|
}
|
||||||
|
|
||||||
def evalExprIntoReg(expr: Expr, dest: Register)
|
def evalExprIntoReg(expr: Expr, dest: Register)(using
|
||||||
(using stack: LinkedHashMap[Ident, Int], strings: ListBuffer[String]): List[AsmLine] = {
|
stack: LinkedHashMap[Ident, Int],
|
||||||
|
strings: ListBuffer[String]
|
||||||
|
): List[AsmLine] = {
|
||||||
var src: Src = ImmediateVal(0) // Placeholder
|
var src: Src = ImmediateVal(0) // Placeholder
|
||||||
(expr match {
|
(expr match {
|
||||||
case IntLiter(v) =>
|
case IntLiter(v) =>
|
||||||
@ -78,11 +86,18 @@ object asmGenerator {
|
|||||||
IndexAddress(Register(RegSize.R64, RegName.SP), (stack.size - stack(ident)) * 4)
|
IndexAddress(Register(RegSize.R64, RegName.SP), (stack.size - stack(ident)) * 4)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
case ArrayLiter(elems) => expr.ty match {
|
case ArrayLiter(elems) =>
|
||||||
|
expr.ty match {
|
||||||
case KnownType.Char =>
|
case KnownType.Char =>
|
||||||
strings += elems.mkString
|
strings += elems.mkString
|
||||||
List(
|
List(
|
||||||
Load(dest, IndexAddress(Register(RegSize.R64, RegName.IP),LabelArg(s".L.str${strings.size - 1}")))
|
Load(
|
||||||
|
dest,
|
||||||
|
IndexAddress(
|
||||||
|
Register(RegSize.R64, RegName.IP),
|
||||||
|
LabelArg(s".L.str${strings.size - 1}")
|
||||||
|
)
|
||||||
|
)
|
||||||
)
|
)
|
||||||
case _ => List()
|
case _ => List()
|
||||||
}
|
}
|
||||||
|
@ -98,7 +98,8 @@ object assemblyIR {
|
|||||||
case class Call(op1: CLibFunc | LabelArg) extends Operation("call", op1)
|
case class Call(op1: CLibFunc | LabelArg) extends Operation("call", op1)
|
||||||
|
|
||||||
case class Move(op1: Dest, op2: Src) extends Operation("mov", op1, op2)
|
case class Move(op1: Dest, op2: Src) extends Operation("mov", op1, op2)
|
||||||
case class Load(op1: Register, op2: MemLocation | IndexAddress) extends Operation("lea ", op1, op2)
|
case class Load(op1: Register, op2: MemLocation | IndexAddress)
|
||||||
|
extends Operation("lea ", op1, op2)
|
||||||
|
|
||||||
case class Return() extends Operation("ret")
|
case class Return() extends Operation("ret")
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user