Skip to content

objc_msgSend: powerpc64* support#386

Open
pkubaj wants to merge 1 commit into
gnustep:masterfrom
pkubaj:ppc64_support
Open

objc_msgSend: powerpc64* support#386
pkubaj wants to merge 1 commit into
gnustep:masterfrom
pkubaj:ppc64_support

Conversation

@pkubaj
Copy link
Copy Markdown

@pkubaj pkubaj commented May 18, 2026

Works on both little- and big-endian.

Works on both little- and big-endian.
@davidchisnall
Copy link
Copy Markdown
Member

This looks technically correct, but seems to be somewhat missing the point of the assembly implementations. This always hits the slow path and will be slower than the portable mechanism.

Comment thread objc_msgSend.powerpc64.S

/* Prologue: save LR, create frame, save TOC */
mflr 0
stdu 1, -FRAME_SIZE(1)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think you want a cfi_def_cfa_offset here.

Comment thread objc_msgSend.powerpc64.S
lfd 13, 192(1)

/* Tear down frame and restore LR */
addi 1, 1, FRAME_SIZE
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

And here a cfi_adjust_cfa_offset again

Comment thread objc_msgSend.powerpc64.S
nop

/* Move returned IMP to r12 (required for ELFv2 indirect calls) */
mr 12, 3
Copy link
Copy Markdown
Member

@hmelder hmelder May 19, 2026

Choose a reason for hiding this comment

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

Is there a reason for using register indices instead of %r<NUMBER> and %f<NUMBER>? It makes it cumbersome to read.

Comment thread objc_msgSend.powerpc64.S
.globl CDECL(objc_msgSend_stret)
TYPE_DIRECTIVE(CDECL(objc_msgSend_stret), %function)

/* For stret methods: r3=hidden struct ptr, r4=self, r5=sel */
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You can use a macro and save the duplication here. Checkout my draft objc_msgSend.powerpc.S here:

MSGSEND %r4, %r5 // Pointer to stack frame in %r3

@hmelder
Copy link
Copy Markdown
Member

hmelder commented May 19, 2026

I agree with David that there is no point in having this assembly trampoline if you always take the slow path. Maybe base it around my already existing draft. The draft is basically a translation of the RISC-V trampoline.

#define ARGUMENT_SPILL_SIZE (3*8 + 8*8 + 14*8)

@hmelder
Copy link
Copy Markdown
Member

hmelder commented May 19, 2026

Also enabling this requires an additional patch in CGObjCGNU.cpp in Clang codegen to actually emit calls to objc_msgSend and friends.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants