Skip to content
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

[AsmWriterEmitter] Alias priority is ignored #29

Open
Rot127 opened this issue Aug 8, 2023 · 0 comments
Open

[AsmWriterEmitter] Alias priority is ignored #29

Rot127 opened this issue Aug 8, 2023 · 0 comments

Comments

@Rot127
Copy link
Collaborator

Rot127 commented Aug 8, 2023

When alias are emitter the priority is ignored. Only priority = 0 (do not emit) is handled.

Because of this we can not decide, which alias should be emitted in case of a collision.

E.g.

bta eq, 0x400 ; Emitter
beqa 0x400 ; Should be emitter

Possibly it is enough to sort the AliasMap before adding each alias to the IAPrinter:

typedef std::set<std::pair<CodeGenInstAlias, int>, AliasPriorityComparator>
AliasWithPriority;
std::map<std::string, AliasWithPriority> AliasMap;
for (Record *R : AllInstAliases) {
int Priority = R->getValueAsInt("EmitPriority");
if (Priority < 1)
continue; // Aliases with priority 0 are never emitted.
const DagInit *DI = R->getValueAsDag("ResultInst");
AliasMap[getQualifiedName(DI->getOperatorAsDef(R->getLoc()))].insert(
std::make_pair(CodeGenInstAlias(R, Target), Priority));
}
// A map of which conditions need to be met for each instruction operand
// before it can be matched to the mnemonic.
std::map<std::string, std::vector<IAPrinter>> IAPrinterMap;
std::vector<std::pair<std::string, bool>> PrintMethods;
// A list of MCOperandPredicates for all operands in use, and the reverse map
std::vector<const Record*> MCOpPredicates;
DenseMap<const Record*, unsigned> MCOpPredicateMap;
for (auto &Aliases : AliasMap) {
// Collection of instruction alias rules. May contain ambiguous rules.
std::vector<IAPrinter> IAPs;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant