Skip to content

Commit 1b782d8

Browse files
committed
[Xtensa] Implement MUL16 feature.
1 parent cb57f8b commit 1b782d8

File tree

5 files changed

+44
-8
lines changed

5 files changed

+44
-8
lines changed

llvm/lib/Target/Xtensa/Xtensa.td

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ def FeatureNSA : SubtargetFeature<"nsa", "HasNSA", "true",
5252
def HasNSA : Predicate<"Subtarget->hasNSA()">,
5353
AssemblerPredicate<(all_of FeatureNSA)>;
5454

55+
def FeatureMul16 : SubtargetFeature<"mul16", "HasMul16", "true",
56+
"Enable Xtensa Mul16 option">;
57+
def HasMul16 : Predicate<"Subtarget->hasMul16()">,
58+
AssemblerPredicate<(all_of FeatureMul16)>;
59+
5560
def FeatureMul32 : SubtargetFeature<"mul32", "HasMul32", "true",
5661
"Enable Xtensa Mul32 option">;
5762
def HasMul32 : Predicate<"Subtarget->hasMul32()">,
@@ -171,20 +176,20 @@ class Proc<string Name, list<SubtargetFeature> Features>
171176

172177
def : Proc<"generic", []>;
173178

174-
def : Proc<"esp32", [FeatureDensity, FeatureSingleFloat, FeatureLoop, FeatureMAC16, FeatureWindowed, FeatureBoolean,
175-
FeatureSEXT, FeatureNSA, FeatureMul32, FeatureMul32High, FeatureDFPAccel, FeatureS32C1I, FeatureTHREADPTR, FeatureDiv32,
179+
def : Proc<"esp32", [FeatureDensity, FeatureSingleFloat, FeatureLoop, FeatureMAC16, FeatureWindowed, FeatureBoolean, FeatureSEXT,
180+
FeatureNSA, FeatureMul16, FeatureMul32, FeatureMul32High, FeatureDFPAccel, FeatureS32C1I, FeatureTHREADPTR, FeatureDiv32,
176181
FeatureATOMCTL, FeatureMEMCTL, FeatureDebug, FeatureException, FeatureHighPriInterrupts, FeatureCoprocessor,
177182
FeatureInterrupt, FeatureRelocatableVector, FeatureTimerInt, FeaturePRID, FeatureRegionProtection, FeatureMiscSR]>;
178183

179-
def : Proc<"esp8266", [FeatureDensity, FeatureNSA, FeatureMul32, FeatureExtendedL32R, FeatureDebug, FeatureException, FeatureHighPriInterrupts,
180-
FeatureInterrupt, FeatureRelocatableVector, FeatureTimerInt, FeatureRegionProtection, FeaturePRID]>;
184+
def : Proc<"esp8266", [FeatureDensity, FeatureNSA, FeatureMul16, FeatureMul32, FeatureExtendedL32R, FeatureDebug, FeatureException,
185+
FeatureHighPriInterrupts, FeatureInterrupt, FeatureRelocatableVector, FeatureTimerInt, FeatureRegionProtection, FeaturePRID]>;
181186

182-
def : Proc<"esp32-s2", [FeatureDensity, FeatureWindowed, FeatureSEXT, FeatureNSA, FeatureMul32, FeatureMul32High, FeatureTHREADPTR, FeatureDiv32,
183-
FeatureMEMCTL, FeatureDebug, FeatureException, FeatureHighPriInterrupts, FeatureCoprocessor, FeatureInterrupt,
187+
def : Proc<"esp32-s2", [FeatureDensity, FeatureWindowed, FeatureSEXT, FeatureNSA, FeatureMul16, FeatureMul32, FeatureMul32High, FeatureTHREADPTR,
188+
FeatureDiv32, FeatureMEMCTL, FeatureDebug, FeatureException, FeatureHighPriInterrupts, FeatureCoprocessor, FeatureInterrupt,
184189
FeatureRelocatableVector, FeatureTimerInt, FeaturePRID, FeatureRegionProtection, FeatureMiscSR, FeatureESP32S2Ops]>;
185190

186-
def : Proc<"esp32-s3", [FeatureDensity, FeatureSingleFloat, FeatureLoop, FeatureMAC16, FeatureWindowed, FeatureBoolean,
187-
FeatureSEXT, FeatureNSA, FeatureMul32, FeatureMul32High, FeatureDFPAccel, FeatureS32C1I, FeatureTHREADPTR, FeatureDiv32,
191+
def : Proc<"esp32-s3", [FeatureDensity, FeatureSingleFloat, FeatureLoop, FeatureMAC16, FeatureWindowed, FeatureBoolean, FeatureSEXT,
192+
FeatureNSA, FeatureMul16, FeatureMul32, FeatureMul32High, FeatureDFPAccel, FeatureS32C1I, FeatureTHREADPTR, FeatureDiv32,
188193
FeatureATOMCTL, FeatureMEMCTL, FeatureDebug, FeatureException, FeatureHighPriInterrupts, FeatureCoprocessor,
189194
FeatureInterrupt, FeatureRelocatableVector, FeatureTimerInt, FeaturePRID, FeatureRegionProtection, FeatureMiscSR,
190195
FeatureESP32S3Ops]>;

llvm/lib/Target/Xtensa/XtensaInstrInfo.td

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1322,6 +1322,17 @@ def NSAU : RRR_Inst<0x00, 0x00, 0x04, (outs AR:$t), (ins AR:$s),
13221322
let r = 0xF;
13231323
}
13241324

1325+
//===----------------------------------------------------------------------===//
1326+
// Mul16 Instructions
1327+
//===----------------------------------------------------------------------===//
1328+
1329+
let Predicates = [HasMul16] in {
1330+
def MUL16S : RRR_Inst<0x00, 0x01, 0x0D, (outs AR:$r), (ins AR:$s, AR:$t),
1331+
"mul16s\t$r, $s, $t", []>;
1332+
def MUL16U : RRR_Inst<0x00, 0x01, 0x0C, (outs AR:$r), (ins AR:$s, AR:$t),
1333+
"mul16u\t$r, $s, $t", []>;
1334+
}
1335+
13251336
//===----------------------------------------------------------------------===//
13261337
// Mul32 Instructions
13271338
//===----------------------------------------------------------------------===//

llvm/lib/Target/Xtensa/XtensaSubtarget.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ XtensaSubtarget::initializeSubtargetDependencies(StringRef CPU, StringRef FS) {
3939
HasLoop = false;
4040
HasSEXT = false;
4141
HasNSA = false;
42+
HasMul16 = false;
4243
HasMul32 = false;
4344
HasMul32High = false;
4445
HasDiv32 = false;

llvm/lib/Target/Xtensa/XtensaSubtarget.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ class XtensaSubtarget : public XtensaGenSubtargetInfo {
5959
// Enable Xtensa NSA option
6060
bool HasNSA;
6161

62+
// Enable Xtensa Mul16 option
63+
bool HasMul16;
64+
6265
// Enable Xtensa Mul32 option
6366
bool HasMul32;
6467

@@ -156,6 +159,8 @@ class XtensaSubtarget : public XtensaGenSubtargetInfo {
156159

157160
bool hasNSA() const { return HasNSA; }
158161

162+
bool hasMul16() const { return HasMul16; }
163+
159164
bool hasMul32() const { return HasMul32; }
160165

161166
bool hasMul32High() const { return HasMul32High; }
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# RUN: llvm-mc %s -triple=xtensa -mattr=+mul16 -show-encoding \
2+
# RUN: | FileCheck -check-prefixes=CHECK,CHECK-INST %s
3+
4+
5+
.align 4
6+
LBL0:
7+
8+
# CHECK-INST: mul16s a2, a3, a4
9+
# CHECK: encoding: [0x40,0x23,0xd1]
10+
mul16s a2, a3, a4
11+
12+
# CHECK-INST: mul16u a2, a3, a4
13+
# CHECK: encoding: [0x40,0x23,0xc1]
14+
mul16u a2, a3, a4

0 commit comments

Comments
 (0)