-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[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
[Xtensa] Lower GlobalAddress/BlockAddress/JumpTable #95256
Conversation
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.
@arsenm , @MaskRay , @s-barannikov , PTAL to this PR whenever you have the time. |
*OutStreamer, | ||
MCInstBuilder(Xtensa::JX).addReg(MI->getOperand(0).getReg())); | ||
return; | ||
} |
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.
Needs a default?
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 created "default" case
|
||
if (XtensaSym->isPrivateLinkage()) | ||
SymName = ".L" + SymName; | ||
MCSym = GetExternalSymbolSymbol(StringRef(SymName)); |
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.
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?
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 substituted GetExternalSymbolSymbol to getOrCreateSymbol, hope I understood proposed solution correctly.
auto PtrVt = getPointerTy(DAG.getDataLayout()); | ||
const GlobalValue *GV = G->getGlobal(); | ||
|
||
// Check Op SDNode users |
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 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
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.
Thank you very much for comment! I removed redundant code.
Remove redundant code and correct pointer type variable initialization. Also improve asm printing.
8d7a687
to
ad41a69
Compare
MCSym = OutContext.getOrCreateSymbol(Twine(DL.getPrivateGlobalPrefix()) + | ||
SymName); |
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 think something further down is supposed to append the prefix for you but I'm no MC expert
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'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.
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.