[LLVMdev] questions
Bill? Wendling
wendling at isanbard.org
Tue Sep 17 11:39:00 PDT 2002
Also sprach xli3 at 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 at isanbard.org
More information about the llvm-dev
mailing list