[llvm] [SystemZ][z/OS] Continuation of __ptr32 support (PR #103393)
Neumann Hon via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 13 16:28:04 PDT 2024
================
@@ -0,0 +1,375 @@
+; RUN: llc < %s -mtriple s390x-ibm-zos | FileCheck %s
+; Source to regenerate:
+; struct Foo {
+; int * __ptr32 p32;
+; int *p64;
+; char *cp64;
+; };
+; void use_foo(Foo *f);
+;
+; // Assiging a ptr32 value to a 64-bit pointer
+; void ptr32_to_ptr(Foo *f, int * __ptr32 i) {
+; f->p64 = i;
+; use_foo(f);
+; }
+;
+; // Assigning a 64-bit ptr value to a ptr32
+; void ptr_to_ptr32(Foo *f, int *i) {
+; f->p32 = i;
+; use_foo(f);
+; }
+;
+; // Assigning a ptr32 value to a ptr32 value
+; void ptr32_to_ptr32(Foo *f, int * __ptr32 i) {
+; f->p32 = i;
+; use_foo(f);
+; }
+;
+; void ptr_to_ptr(Foo *f, int *i) {
+; f->p64 = i;
+; use_foo(f);
+; }
+;
+; void test_indexing(Foo *f) {
+; f->cp64 = ((char * __ptr32 *)1028)[1];
+; use_foo(f);
+; }
+;
+; void test_indexing_2(Foo *f) {
+; f->cp64 = ((char *** __ptr32 *)1028)[1][2][3];
+; use_foo(f);
+; }
+;
+; unsigned long* test_misc() {
+; unsigned long* x = (unsigned long*)((char***** __ptr32*)1208)[0][11][1][113][149];
+; return x;
+; }
+;
+; char* __ptr32* __ptr32 test_misc_2() {
+; static char* __ptr32* __ptr32 res = 0;
+; if (res == 0) {
+; res = ((char* __ptr32* __ptr32* __ptr32* __ptr32*)0)[4][136][6];
+; }
+; return res;
+; }
+;
+; unsigned short test_misc_3() {
+; unsigned short this_asid = ((unsigned short*)(*(char* __ptr32*)(0x224)))[18];
+; return this_asid;
+; }
+;
+; int test_misc_4() {
+; int a = (*(int*)(80 + ((char**** __ptr32*)1208)[0][11][1][123]) > 0x040202FF);
+; return a;
+; }
+;
+; void test_misc_5(struct Foo *f) {
+; f->cp64 = *(char* __ptr32 *)(PSA_PTR + PSAAOLD);
+; use_foo(f);
+; }
+;
+; int get_processor_count() {
+; return ((char * __ptr32 * __ptr32 *)0)[4][165][53];
+; }
+;
+; void spill_ptr32_args_to_registers( char *__ptr32 p ) {
+; void g ( int, ... );
+; g ( 5, p, p, p, p, p );
+; }
+;
+; $ clang -cc1 -triple s390x-ibm-zos -fzos-extensions -O2 -S t.cpp
+;
+; For the last test case:
+;
+;#include <stdlib.h>
+;
+;int foo();
+;
+;typedef struct qa_area {/* Area descriptor */
+; char* __ptr32 text; /* Start address of area */
+; int length; /* Size of area in bytes */
+;} qa_area;
+;
+;int main() {
+; qa_area* __ptr32 fap_asm_option_a = (qa_area*)__malloc31(sizeof(qa_area));
+;
+; //((qa_area*)fap_asm_option_a)->length = foo(); //PASSES
+; fap_asm_option_a->length = foo(); //CRASHES
+; return 0;
+;}
+
+%struct.Foo = type { i32 addrspace(1)*, i32*, i8* }
----------------
Everybody0523 wrote:
Can you use opaque pointers here (and also elsewhere in the file)?
https://github.com/llvm/llvm-project/pull/103393
More information about the llvm-commits
mailing list