Skip to content

Commit 81bcb2c

Browse files
b-s-aadriweb
authored andcommitted
[Z80] Add feature to enable SLI/SLL instruction
1 parent f68e408 commit 81bcb2c

File tree

4 files changed

+17
-4
lines changed

4 files changed

+17
-4
lines changed

llvm/lib/Target/Z80/Z80.td

+3-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ def FeatureEZ80 : SubtargetFeature<"ez80", "HasEZ80Ops", "true",
2828
"Support ez80 instructions">;
2929
def FeatureIdxHalf : SubtargetFeature<"idxhalf", "HasIdxHalfRegs", "true",
3030
"Support index half registers">;
31+
def FeatureSli : SubtargetFeature<"sli", "HasSliOps", "true",
32+
"Support SLI instruction">;
3133

3234
//===----------------------------------------------------------------------===//
3335
// Z80 Subtarget state
@@ -46,7 +48,7 @@ let CompleteModel = 0 in def GenericModel : SchedMachineModel;
4648
class Proc<string Name, list<SubtargetFeature> Features>
4749
: ProcessorModel<Name, GenericModel, Features>;
4850
def : Proc<"generic", []>;
49-
def : Proc<"z80", [FeatureUndoc, FeatureIdxHalf]>;
51+
def : Proc<"z80", [FeatureUndoc, FeatureIdxHalf, FeatureSli]>;
5052
def : Proc<"z180", [FeatureZ180]>;
5153
def : Proc<"ez80", [FeatureZ180, FeatureEZ80, FeatureIdxHalf]>;
5254

llvm/lib/Target/Z80/Z80InstrInfo.td

+9-3
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ def Z80rl_flag : SDNode<"Z80ISD::RL", SDTUnOpRFF>;
8282
def Z80rr_flag : SDNode<"Z80ISD::RR", SDTUnOpRFF>;
8383
def Z80sla_flag : SDNode<"Z80ISD::SLA", SDTUnOpRF>;
8484
def Z80sra_flag : SDNode<"Z80ISD::SRA", SDTUnOpRF>;
85+
def Z80sli_flag : SDNode<"Z80ISD::SLI", SDTUnOpRF>;
8586
def Z80srl_flag : SDNode<"Z80ISD::SRL", SDTUnOpRF>;
8687
def Z80bit_flag : SDNode<"Z80ISD::BIT", SDTBitOpF>;
8788
def Z80res_flag : SDNode<"Z80ISD::RES", SDTBitOpR>;
@@ -132,8 +133,9 @@ def HaveZ180Ops : Predicate<"Subtarget->hasZ180Ops()">,
132133
def HaveEZ80Ops : Predicate<"Subtarget->hasEZ80Ops()">,
133134
AssemblerPredicate<(all_of FeatureEZ80), "eZ80 ops">;
134135
def HaveIdxHalf : Predicate<"Subtarget->hasIndexHalfRegs()">,
135-
AssemblerPredicate<(all_of FeatureIdxHalf),
136-
"index half regs">;
136+
AssemblerPredicate<"FeatureIdxHalf", "index half regs">;
137+
def HaveSliOps : Predicate<"Subtarget->hasSliOps()">,
138+
AssemblerPredicate<"FeatureSli", "sli ops">;
137139

138140
//===----------------------------------------------------------------------===//
139141
// Z80 Instruction Format Definitions.
@@ -805,6 +807,8 @@ defm RL : UnOp8RFF <CBPre, 2, "rl">;
805807
defm RR : UnOp8RFF <CBPre, 3, "rr">;
806808
defm SLA : UnOp8RF <CBPre, 4, "sla">;
807809
defm SRA : UnOp8RF <CBPre, 5, "sra">;
810+
defm SLI : UnOp8RF <CBPre, 6, "sli">,
811+
Requires<[HaveSliOps]>;
808812
defm SRL : UnOp8RF <CBPre, 7, "srl">;
809813
defm BIT : BitOp8F < 1, "bit">;
810814
defm RES : BitOp8R < 2, "res">;
@@ -820,7 +824,9 @@ defm XOR : BinOp8RF <NoPre, 5, "xor">;
820824
defm OR : BinOp8RF <NoPre, 6, "or", 1>;
821825
defm CP : BinOp8F <NoPre, 7, "cp", 1>;
822826
defm TST : BinOp8F <EDPre, 4, "tst", 1>,
823-
Requires<[HaveEZ80Ops]>;
827+
Requires<[HaveZ180Ops]>;
828+
829+
def : MnemonicAlias<"sll", "sli">, Requires<[HaveSliOps]>;
824830

825831
def : Pat<(fshl G8:$reg, G8:$reg, (i8 1)), (RLC8r G8:$reg)>;
826832
def : Pat<(fshl G8:$reg, G8:$reg, (i8 7)), (RRC8r G8:$reg)>;

llvm/lib/Target/Z80/Z80Subtarget.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ Z80Subtarget &Z80Subtarget::initializeSubtargetDependencies(StringRef CPU,
3535
CPU = TargetTriple.getArchName();
3636
ParseSubtargetFeatures(CPU, TuneCPU, FS);
3737
HasIdxHalfRegs = HasUndocOps || HasEZ80Ops;
38+
HasSliOps = HasUndocOps;
3839
return *this;
3940
}
4041

llvm/lib/Target/Z80/Z80Subtarget.h

+4
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ class Z80Subtarget final : public Z80GenSubtargetInfo {
5252
/// True if target has index half registers (HasUndocOps || HasEZ80Ops).
5353
bool HasIdxHalfRegs = false;
5454

55+
/// True if target has SLI (also known SLL) instructions (HasUndocOps)
56+
bool HasSliOps = false;
57+
5558
// Ordering here is important. Z80InstrInfo initializes Z80RegisterInfo which
5659
// Z80TargetLowering needs.
5760
Z80InstrInfo InstrInfo;
@@ -118,6 +121,7 @@ class Z80Subtarget final : public Z80GenSubtargetInfo {
118121
bool hasZ180Ops() const { return HasZ180Ops; }
119122
bool hasEZ80Ops() const { return HasEZ80Ops; }
120123
bool hasIndexHalfRegs() const { return HasIdxHalfRegs; }
124+
bool hasSliOps() const { return HasSliOps; }
121125
bool has24BitEZ80Ops() const { return is24Bit() && hasEZ80Ops(); }
122126
bool has16BitEZ80Ops() const { return is16Bit() && hasEZ80Ops(); }
123127
};

0 commit comments

Comments
 (0)