[prev in list] [next in list] [prev in thread] [next in thread]
List: llvm-dev
Subject: RE: [LLVMdev] questions
From: "Vikram S. Adve" <vadve () cs ! uiuc ! edu>
Date: 2002-09-17 16:56:01
Message-ID: ICEKLEDJJHPJGBCFHJHEEEFECCAA.vadve () cs ! uiuc ! edu
[Download RAW message or body]
You do not have to (and should not) transform a struct if it is passed as an
argument to a procedure.
--Vikram
----------------------------------------------------------------------
VIKRAM S. ADVE
Assistant Professor E-MAIL: vadve@cs.uiuc.edu
Department of Computer Science PHONE: (217) 244-2016
Univ. of Illinois at Urbana-Champaign FAX: (217) 244-6869
1304 W. Springfield Ave. http://www.cs.uiuc.edu/~vadve
Urbana IL 61801.
----------------------------------------------------------------------
> -----Original Message-----
> From: llvmdev-admin@cs.uiuc.edu [mailto:llvmdev-admin@cs.uiuc.edu]On
> Behalf Of Bill? Wendling
> Sent: Tuesday, September 17, 2002 11:39 AM
> To: xli3@uiuc.edu
> Cc: llvmdev@cs.uiuc.edu
> Subject: Re: [LLVMdev] questions
>
>
> Also sprach xli3@uiuc.edu:
> } Sorry I got really overwhelmed by so many classes and member
> } functions in LLVM. So would you please clarify some problems
> } I have?
> }
> } 1. If I see this instruction in the function.
> }
> } %S.i = alloca %struct.SimpleStruct
> }
> } Suppose SimpleStruct is as following:
> } struct.SimpleStruct = type { int, double }
> }
> } When I read the instruction, how can I know the type of
> } simplstruct, should I use 'getType' member function like
> } Inst.getType()? If I use that, I will get a PointerType, how
> } can I use it?
> }
> I used the "dyn_cast<>" method to dynamically check whether something is
> of a given type. dyn_cast<> helpfully returns 0 if it's not of that type.
> So, you can do something like:
>
> if (const PointerType *PT = dyn_cast<PointerType>(Inst.getType()))
> if (const StructType *ST = dyn_cast<StructType>(PT->getType()))
> // Work with ST...
>
> and it'll work.
>
> } 2. Another question is that since we do the scalar replacement
> } on each function. If the program look like this.
> }
> } struct s {
> } int a;
> } float b;
> } }
> } fun1( struct s *ps) {
> } ps->a = 1;
> } ps->b = 2;
> } }
> } main( )
> } {
> } struct s mystru;
> }
> } fun1( &mystru );
> } }
> }
> } When we process the function 'fun1', should we change fun1 to
> } something like
> } fun1( int *a, float *b )
> } then change fun1(&mystru) in main to something like
> } fun1( &mystru.a, &mystru.b)?
> }
> I assume that, since "mystru" isn't being used as specified in rules
> U1-U3, that we shouldn't have to handle it...
>
> But I could be wrong...
>
> *crosses fingers, hoping he's not wrong*
>
> --
> || Bill? Wendling wendling@isanbard.org
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev@cs.uiuc.edu http://llvm.cs.uiuc.edu
> http://mail.cs.uiuc.edu/mailman/listinfo/llvmdev
>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic