[LLVMdev] generating function declarations in c frontend

Michael McCracken michael.mccracken at gmail.com
Tue Oct 5 21:00:41 PDT 2004


I'm trying to generate the declarations for function intrinsics, and I
must be misunderstanding how to create new functions - I saw that a
function with no basic blocks is treated as a declaration, so I tried
to just create one and add it to the globals list:

  llvm_type *structTy, *ptrToStructTy;

  structTy = llvm_type_create_struct(0, 0);
  structTy = llvm_type_get_cannonical_struct(structTy);
  ptrToStructTy = llvm_type_get_pointer(structTy);

  llvm_function *dbg_stoppoint_fn = llvm_function_new(ptrToStructTy,
"llvm.dbg.stoppoint");
  llvm_argument *arg = llvm_argument_new(structTy, "foo");
  llvm_ilist_push_back(llvm_value, dbg_stoppoint_fn->Arguments, arg);
/* line # 548 */

  llvm_ilist_push_back(llvm_global, TheProgram.Globals, dbg_stoppoint_fn);
  
  
This doesn't compile, but at first glance I'm not sure why, since I
see in other places an llvm_argument being created then added to the
Arguments list in the exact same way.

../../src/gcc/llvm-expand.c:548: warning: initialization from
incompatible pointer type
../../src/gcc/llvm-expand.c:548: warning: initialization from
incompatible pointer type
../../src/gcc/llvm-expand.c:548: error: structure has no member named `Next'
../../src/gcc/llvm-expand.c:548: error: structure has no member named `Next'
../../src/gcc/llvm-expand.c:548: error: structure has no member named `Prev'
../../src/gcc/llvm-expand.c:548: error: structure has no member named `Prev'
../../src/gcc/llvm-expand.c:548: error: structure has no member named `Prev'
../../src/gcc/llvm-expand.c:548: error: structure has no member named `Prev'
../../src/gcc/llvm-expand.c:548: error: structure has no member named `Prev'
../../src/gcc/llvm-expand.c:550: warning: initialization from
incompatible pointer type

What am I missing?

Thanks,
-mike

-- 
Michael McCracken
UCSD CSE PhD Student
San Diego Supercomputer Center
http://www.cse.ucsd.edu/~mmccrack/




More information about the llvm-dev mailing list