示例#1
0
文件: abi-win64.cpp 项目: hbarve1/ldc
void Win64TargetABI::rewriteArgument(IrFuncTy& fty, IrFuncTyArg& arg)
{
    LLType* originalLType = arg.ltype;
    Type* t = arg.type->toBasetype();

    if (isPassedWithByvalSemantics(t))
    {
        // these types are passed byval:
        // the caller allocates a copy and then passes a pointer to the copy
        arg.rewrite = &byvalRewrite;
        arg.ltype = byvalRewrite.type(arg.type, arg.ltype);

        // the copy is treated as a local variable of the callee
        // hence add the NoAlias and NoCapture attributes
        arg.attrs.clear()
                 .add(LDC_ATTRIBUTE(NoAlias))
                 .add(LDC_ATTRIBUTE(NoCapture));
    }
    else if (isAggregate(t) && canRewriteAsInt(t) && !IntegerRewrite::isObsoleteFor(originalLType))
    {
        arg.rewrite = &integerRewrite;
        arg.ltype = integerRewrite.type(arg.type, arg.ltype);
    }

    IF_LOG if (arg.rewrite)
    {
        Logger::println("Rewriting argument type %s", t->toChars());
        LOG_SCOPE;
        Logger::cout() << *originalLType << " => " << *arg.ltype << '\n';
    }
}
示例#2
0
文件: abi-ppc64.cpp 项目: Axure/ldc
    void rewriteArgument(IrFuncTy& fty, IrFuncTyArg& arg)
    {
        Type* ty = arg.type->toBasetype();

        if (ty->ty == Tstruct || ty->ty == Tsarray)
        {
            if (canRewriteAsInt(ty))
            {
                arg.rewrite = &integerRewrite;
                arg.ltype = integerRewrite.type(arg.type, arg.ltype);
            }
            else
            {
                // these types are passed byval:
                // the caller allocates a copy and then passes a pointer to the copy
                arg.rewrite = &byvalRewrite;
                arg.ltype = byvalRewrite.type(arg.type, arg.ltype);

                // the copy is treated as a local variable of the callee
                // hence add the NoAlias and NoCapture attributes
                arg.attrs.clear()
                         .add(LDC_ATTRIBUTE(NoAlias))
                         .add(LDC_ATTRIBUTE(NoCapture));
            }
        }
    }
示例#3
0
  void rewriteArgument(IrFuncTy &fty, IrFuncTyArg &arg) override {
    Type *ty = arg.type->toBasetype();

    if (ty->ty == Tstruct || ty->ty == Tsarray) {
      if (canRewriteAsInt(ty, Is64Bit)) {
        if (!IntegerRewrite::isObsoleteFor(arg.ltype)) {
          arg.rewrite = &integerRewrite;
          arg.ltype = integerRewrite.type(arg.type, arg.ltype);
        }
      } else {
        // these types are passed byval:
        // the caller allocates a copy and then passes a pointer to the copy
        arg.rewrite = &byvalRewrite;
        arg.ltype = byvalRewrite.type(arg.type, arg.ltype);

        // the copy is treated as a local variable of the callee
        // hence add the NoAlias and NoCapture attributes
        arg.attrs.clear()
            .add(LLAttribute::NoAlias)
            .add(LLAttribute::NoCapture)
            .addAlignment(byvalRewrite.alignment(arg.type));
      }
    }
  }