GetParameter() public method

public GetParameter ( uint index ) : Value
index uint
return Value
Beispiel #1
0
        public Function CodeGen(IRBuilder builder)
        {
            List<TypeRef> args = new List<TypeRef>();
            this.Args.ForEach(a => args.Add(TypeRef.CreateDouble()));

            Function func = new Function(CodeGenManager.Module, this.Name,
                                                 TypeRef.CreateDouble(), args.ToArray());
            func.SetLinkage(LLVMLinkage.ExternalLinkage);

            // If F conflicted, there was already something named 'Name'.  If it has a
            // body, don't allow redefinition or reextern.
            if(func.IsDuplicate())
            {
                // Delete the one we just made and get the existing one.
                func.Delete();
                func = CodeGenManager.Module.GetFunction(this.Name);

                // If F already has a body, reject this.
                if(func.HasBody)
                {
                    CodeGenManager.ErrorOutput.WriteLine("redefinition of function.");
                    return null;
                }

                // If F took a different number of args, reject.
                if(func.ArgCount != this.Args.Count)
                {
                    CodeGenManager.ErrorOutput.WriteLine("redefinition of function with different # args.");
                    return null;
                }
            }

            // Set names for all arguments.
            for(int i = 0; i < func.ArgCount; ++i)
            {
                Value val = func.GetParameter((uint)i);
                val.Name = this.Args[i];
                CodeGenManager.NamedValues[this.Args[i]] = val;
            }

            return func;
        }
Beispiel #2
0
 public void CreateArgAllocas(Function function, IRBuilder builder)
 {
     for(int i = 0; i < function.ArgCount; ++i)
     {
         Value alloca = builder.BuildEntryBlockAlloca(function, TypeRef.CreateDouble(), this.Args[i]);
         builder.BuildStore(function.GetParameter((uint)i), alloca);
         CodeGenManager.NamedValues[this.Args[i]] = alloca;
     }
 }