-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[PowerPC][AIX] 64-bit large code-model support for toc-data #90619
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 all commits
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 |
---|---|---|
@@ -1,16 +1,13 @@ | ||
// RUN: %clang -### --target=powerpc-ibm-aix-xcoff -mcmodel=medium -mtocdata %s 2>&1 \ | ||
// RUN: | FileCheck -check-prefix=CHECK-NOTOC %s | ||
// RUN: | FileCheck %s | ||
// RUN: %clang -### --target=powerpc-ibm-aix-xcoff -mcmodel=large -mtocdata %s 2>&1 \ | ||
// RUN: | FileCheck -check-prefix=CHECK-NOTOC %s | ||
// RUN: | FileCheck %s | ||
// RUN: %clang -### --target=powerpc-ibm-aix-xcoff -mtocdata %s 2>&1 \ | ||
// RUN: | FileCheck -check-prefix=CHECK-TOC %s | ||
// RUN: | FileCheck %s | ||
// RUN: %clang -### --target=powerpc64-ibm-aix-xcoff -mcmodel=medium -mtocdata %s 2>&1 \ | ||
// RUN: | FileCheck -check-prefix=CHECK-NOTOC %s | ||
// RUN: | FileCheck %s | ||
// RUN: %clang -### --target=powerpc64-ibm-aix-xcoff -mcmodel=large -mtocdata %s 2>&1 \ | ||
// RUN: | FileCheck -check-prefix=CHECK-NOTOC %s | ||
// RUN: | FileCheck %s | ||
// RUN: %clang -### --target=powerpc64-ibm-aix-xcoff -mtocdata %s 2>&1 \ | ||
// RUN: | FileCheck -check-prefix=CHECK-TOC %s | ||
// CHECK-NOTOC: warning: ignoring '-mtocdata' as it is only supported for -mcmodel=small | ||
// CHECK-NOTOC-NOT: "-cc1"{{.*}}" "-mtocdata" | ||
// CHECK-TOC: "-cc1"{{.*}}" "-mtocdata" | ||
// CHECK-TOC-NOT: warning: ignoring '-mtocdata' as it is only supported for -mcmodel=small | ||
// RUN: | FileCheck %s | ||
// CHECK: "-cc1"{{.*}}" "-mtocdata" |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6143,23 +6143,22 @@ void PPCDAGToDAGISel::Select(SDNode *N) { | |
" ELF/AIX or 32-bit AIX in the following."); | ||
|
||
// Transforms the ISD::TOC_ENTRY node for 32-bit AIX large code model mode, | ||
// or 64-bit medium (ELF-only), or large (ELF and AIX) code model code that | ||
// does not conain TOC data symbols. | ||
// We generate two instructions as described below. The first source | ||
// operand is a symbol reference. If it must be referenced via the toc | ||
// according to Subtarget, we generate: | ||
// 64-bit medium (ELF-only), or 64-bit large (ELF and AIX) code model code | ||
// that does not contain TOC data symbols. We generate two instructions as | ||
// described below. The first source operand is a symbol reference. If it | ||
// must be referenced via the TOC according to Subtarget, we generate: | ||
// [32-bit AIX] | ||
// LWZtocL(@sym, ADDIStocHA(%r2, @sym)) | ||
// [64-bit ELF/AIX] | ||
// LDtocL(@sym, ADDIStocHA8(%x2, @sym)) | ||
// Otherwise we generate: | ||
// Otherwise for medium code model ELF we generate: | ||
// ADDItocL8(ADDIStocHA8(%x2, @sym), @sym) | ||
|
||
// For large code model with TOC data symbols we generate: | ||
// And finally for AIX with toc-data we generate: | ||
// [32-bit AIX] | ||
// ADDItocL(ADDIStocHA(%x2, @sym), @sym) | ||
// [64-bit AIX] | ||
// Currently not supported. | ||
// ADDItocL8(ADDIStocHA8(%x2, @sym), @sym) | ||
|
||
SDValue GA = N->getOperand(0); | ||
SDValue TOCbase = N->getOperand(1); | ||
|
@@ -6171,12 +6170,9 @@ void PPCDAGToDAGISel::Select(SDNode *N) { | |
// On AIX, if the symbol has the toc-data attribute it will be defined | ||
// in the TOC entry, so we use an ADDItocL/ADDItocL8. | ||
if (isAIXABI && hasTocDataAttr(GA)) { | ||
if (isPPC64) | ||
report_fatal_error( | ||
"64-bit large code model toc-data not yet supported"); | ||
|
||
ReplaceNode(N, CurDAG->getMachineNode(PPC::ADDItocL, dl, VT, | ||
SDValue(Tmp, 0), GA)); | ||
ReplaceNode( | ||
N, CurDAG->getMachineNode(isPPC64 ? PPC::ADDItocL8 : PPC::ADDItocL, | ||
dl, VT, SDValue(Tmp, 0), GA)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: I suggest to add an assert like |
||
return; | ||
} | ||
|
||
|
@@ -6191,6 +6187,7 @@ void PPCDAGToDAGISel::Select(SDNode *N) { | |
return; | ||
} | ||
|
||
assert(isPPC64 && "TOC_ENTRY already handled for 32-bit."); | ||
// Build the address relative to the TOC-pointer. | ||
ReplaceNode(N, CurDAG->getMachineNode(PPC::ADDItocL8, dl, MVT::i64, | ||
SDValue(Tmp, 0), GA)); | ||
|
@@ -7777,6 +7774,10 @@ void PPCDAGToDAGISel::PeepholePPC64() { | |
Flags = PPCII::MO_TLSLD_LO; | ||
break; | ||
case PPC::ADDItocL8: | ||
// Skip the following peephole optimizations for ADDItocL8 on AIX which | ||
// is used for toc-data access. | ||
if (Subtarget->isAIXABI()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. curiously , why skip the peephole for the ADDItocL8 in AIX? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a follow on patch for adding this peephole optimization: #76488 since earlier patches related to this were reverted as the code needed some refactoring. |
||
continue; | ||
Flags = PPCII::MO_TOC_LO; | ||
break; | ||
} | ||
|
Uh oh!
There was an error while loading. Please reload this page.
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.
do the patch also support "medium" ? but in the description of the patch , it is "64-bit large code-model" , and do you want to add medium test case?
Uh oh!
There was an error while loading. Please reload this page.
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.
AIX does not have medium model. when specifying it, it will be mapped to large.
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.
Agreed, according to https://reviews.llvm.org/D106371, medium will be large.