diff --git a/lib/Target/Mos6502/Mos6502CallingConv.td b/lib/Target/Mos6502/Mos6502CallingConv.td index 071727a648b..c105423fcb4 100644 --- a/lib/Target/Mos6502/Mos6502CallingConv.td +++ b/lib/Target/Mos6502/Mos6502CallingConv.td @@ -11,11 +11,19 @@ // //===----------------------------------------------------------------------===// +//===----------------------------------------------------------------------===// +// 6502 Return Value Calling Convention +//===----------------------------------------------------------------------===// + def CC_Mos6502 : CallingConv<[ CCIfType<[i8], CCAssignToReg<[A, X, Y]>>, - CCAssignToStack<0, 0> + CCAssignToStack<1, 1> ]>; def RetCC_Mos650232 : CallingConv<[ CCIfType<[i8], CCAssignToReg<[A, X, Y]>> ]>; + +//===----------------------------------------------------------------------===// +// 6502 Argument Calling Conventions +//===----------------------------------------------------------------------===// diff --git a/lib/Target/Mos6502/Mos6502InstrInfo.td b/lib/Target/Mos6502/Mos6502InstrInfo.td index dea056d7fc0..d5167d3e39a 100644 --- a/lib/Target/Mos6502/Mos6502InstrInfo.td +++ b/lib/Target/Mos6502/Mos6502InstrInfo.td @@ -38,6 +38,7 @@ Defs = [A, SREG] in //===----------------------------------------------------------------------===// // Increment and Decrement //===----------------------------------------------------------------------===// + let Defs = [X, SREG] in { def INX : InstM6502<(outs XR:$dst), @@ -64,6 +65,39 @@ let Defs = [Y, SREG] in [(set YR:$dst, (sub YR:$src, 1)), (implicit SREG)]>; } +//===----------------------------------------------------------------------===// +// Stack operations +//===----------------------------------------------------------------------===// + +let Defs = [SP], + Uses = [SP] in +{ + // Push accumulator on stack + let mayStore = 1 in { + def PHA : InstM6502<(outs), (ins AR:$a), "pha", []>; + } + + // Pop from stack into accumulator + let mayLoad = 1 in { + def PLA : InstM6502<(outs AR:$a), (ins), "pla", []>; + } +} + +let Defs = [SP], + Uses = [SP, SREG], + mayStore = 1 in +{ + def PHP : InstM6502<(outs), (ins CCR:$c), "php", []>; +} + +let Defs = [SP, SREG], + Uses = [SP], + mayLoad = 1 in +{ + def PLP : InstM6502<(outs CCR:$c), (ins), "plp", []>; +} + + def NOP : InstM6502<(outs), (ins), "nop", []>; def ADJCALLSTACKDOWN : Pseudo<(outs), (ins), "#ADJCALLSTACKDOWN", []>;