-
Notifications
You must be signed in to change notification settings - Fork 15.5k
[Xtensa] Implement Windowed Register Option. #121118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
bb3de6f
d36e6d2
f7ddb60
79e9b3b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -73,17 +73,42 @@ static DecodeStatus DecodeARRegisterClass(MCInst &Inst, uint64_t RegNo, | |
| return MCDisassembler::Success; | ||
| } | ||
|
|
||
| static const unsigned SRDecoderTable[] = {Xtensa::SAR, 3}; | ||
| // Verify SR | ||
| bool CheckRegister(unsigned RegNo, MCSubtargetInfo STI) { | ||
|
||
| bool Res = true; | ||
|
|
||
| switch (RegNo) { | ||
| case Xtensa::WINDOWBASE: | ||
| case Xtensa::WINDOWSTART: | ||
| Res = STI.getFeatureBits()[Xtensa::FeatureWindowed]; | ||
| break; | ||
| default: | ||
| Res = false; | ||
| break; | ||
| } | ||
|
|
||
| return Res; | ||
| } | ||
|
|
||
| static const unsigned SRDecoderTable[] = { | ||
| Xtensa::SAR, 3, Xtensa::WINDOWBASE, 72, Xtensa::WINDOWSTART, 73}; | ||
|
|
||
| static DecodeStatus DecodeSRRegisterClass(MCInst &Inst, uint64_t RegNo, | ||
| uint64_t Address, | ||
| const void *Decoder) { | ||
| const llvm::MCSubtargetInfo STI = | ||
| ((const MCDisassembler *)Decoder)->getSubtargetInfo(); | ||
|
|
||
| if (RegNo > 255) | ||
| return MCDisassembler::Fail; | ||
|
|
||
| for (unsigned i = 0; i < std::size(SRDecoderTable); i += 2) { | ||
| if (SRDecoderTable[i + 1] == RegNo) { | ||
| unsigned Reg = SRDecoderTable[i]; | ||
|
|
||
| if (!CheckRegister(Reg, STI)) | ||
| return MCDisassembler::Fail; | ||
|
|
||
| Inst.addOperand(MCOperand::createReg(Reg)); | ||
| return MCDisassembler::Success; | ||
| } | ||
|
|
@@ -210,6 +235,29 @@ static DecodeStatus decodeImm32n_95Operand(MCInst &Inst, uint64_t Imm, | |
| return MCDisassembler::Success; | ||
| } | ||
|
|
||
| static DecodeStatus decodeImm8n_7Operand(MCInst &Inst, uint64_t Imm, | ||
| int64_t Address, const void *Decoder) { | ||
| assert(isUInt<4>(Imm) && "Invalid immediate"); | ||
| Inst.addOperand(MCOperand::createImm(Imm > 7 ? Imm - 16 : Imm)); | ||
| return MCDisassembler::Success; | ||
| } | ||
|
|
||
| static DecodeStatus decodeImm64n_4nOperand(MCInst &Inst, uint64_t Imm, | ||
| int64_t Address, | ||
| const void *Decoder) { | ||
| assert(isUInt<6>(Imm) && ((Imm & 0x3) == 0) && "Invalid immediate"); | ||
| Inst.addOperand(MCOperand::createImm((~0x3f) | (Imm))); | ||
| return MCDisassembler::Success; | ||
| } | ||
|
|
||
| static DecodeStatus decodeEntry_Imm12OpValue(MCInst &Inst, uint64_t Imm, | ||
| int64_t Address, | ||
| const void *Decoder) { | ||
| assert(isUInt<15>(Imm) && ((Imm & 0x7) == 0) && "Invalid immediate"); | ||
| Inst.addOperand(MCOperand::createImm(Imm)); | ||
| return MCDisassembler::Success; | ||
| } | ||
|
|
||
| static DecodeStatus decodeShimm1_31Operand(MCInst &Inst, uint64_t Imm, | ||
| int64_t Address, | ||
| const void *Decoder) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| //===----------------------------------------------------------------------===// | ||
| // Xtensa subtarget features. | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| // Xtensa ISA extensions (Xtensa Options). | ||
| def FeatureDensity : SubtargetFeature<"density", "HasDensity", "true", | ||
| "Enable Density instructions">; | ||
| def HasDensity : Predicate<"Subtarget->hasDensity()">, | ||
| AssemblerPredicate<(all_of FeatureDensity)>; | ||
|
|
||
| def FeatureWindowed : SubtargetFeature<"windowed", "HasWindowed", "true", | ||
| "Enable Xtensa Windowed Register option">; | ||
| def HasWindowed : Predicate<"Subtarget->hasWindowed()">, | ||
| AssemblerPredicate<(all_of FeatureWindowed)>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be rewritten with a simpler expression without any conditional assign and break
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I rewrote the function code.