Skip to content

[Xtensa] Lower GlobalAddress/BlockAddress/JumpTable #95256

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

Merged
merged 2 commits into from
Jun 25, 2024

Conversation

andreisfr
Copy link
Contributor

This patch implements lowering of the GlobalAddress, BlockAddress, JumpTable and BR_JT. Also patch adds legal support of the BR_CC operation for i32 type.

This patch implements lowering of the GlobalAddress, BlockAddress, JumpTable
and BR_JT. Also patch adds legal support of the BR_CC operation for i32 type.
@andreisfr
Copy link
Contributor Author

@arsenm , @MaskRay , @s-barannikov , PTAL to this PR whenever you have the time.

*OutStreamer,
MCInstBuilder(Xtensa::JX).addReg(MI->getOperand(0).getReg()));
return;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs a default?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I created "default" case


if (XtensaSym->isPrivateLinkage())
SymName = ".L" + SymName;
MCSym = GetExternalSymbolSymbol(StringRef(SymName));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GetExternalSymbolSymbol uses Twine so you shouldn't need to build a new std::string here for the prefix. Also avoid hardcoding the prefix. Also, can't you just use getOrCreateSymbol? I think that takes care of the prefix?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I substituted GetExternalSymbolSymbol to getOrCreateSymbol, hope I understood proposed solution correctly.

auto PtrVt = getPointerTy(DAG.getDataLayout());
const GlobalValue *GV = G->getGlobal();

// Check Op SDNode users
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This handling doesn't make sense to me and you shouldn't depend on the user context. If you want to fold the global address into an immediate call operand, you can do that in your call handling

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much for comment! I removed redundant code.

Remove redundant code and correct pointer type variable initialization.
Also improve asm printing.
@andreisfr andreisfr force-pushed the xtensa_globaladdr_blockaddr_jumpt branch from 8d7a687 to ad41a69 Compare June 17, 2024 23:19
Comment on lines +81 to +82
MCSym = OutContext.getOrCreateSymbol(Twine(DL.getPrivateGlobalPrefix()) +
SymName);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think something further down is supposed to append the prefix for you but I'm no MC expert

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've found that that "DL.getPrivateGlobalPrefix()" code returns appropriate prefix for Xtensa for private linkage case and such code is used for similar purposes in ARM backend and other backends. So, I used it to substitute hardcoded ".L" prefix.

@sstefan1 sstefan1 merged commit cc8fdd6 into llvm:main Jun 25, 2024
7 checks passed
AlexisPerry pushed a commit to llvm-project-tlp/llvm-project that referenced this pull request Jul 9, 2024
This patch implements lowering of the GlobalAddress, BlockAddress,
JumpTable and BR_JT. Also patch adds legal support of the BR_CC
operation for i32 type.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants