コード例 #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
ファイル: abi-ppc64.cpp プロジェクト: Stretto/Calypso
  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));
      }
    }
  }