int main(){
	char c = 0xe0;
	int a = 0;
	a = c;
	printf("a:0x%x\n", a);
	a = (unsigned char)c;
	printf("a:0x%x\n", a);
	printf("%f\n", foo());

	printf("foo_int %f\n", foo_int(3)); /* 这居然都行!若函数没有float, short , char类型的参数,声明中的形参list可以省略  */ 
	return 1;
}
struct S baz(int i, volatile int *j) {
  // O0-NOT: @llvm.lifetime.start
  // O0-NOT: @llvm.lifetime.end

  struct S r;
  // O1: %[[TMP1_ALLOCA:[^ ]+]] = alloca %struct.S
  // O1: %[[TMP2_ALLOCA:[^ ]+]] = alloca %struct.S
  // O1: br label %[[DO_BODY:.+]]

  do {
    // O1: [[DO_BODY]]:
    // O1: %[[P:[^ ]+]] = bitcast %struct.S* %[[TMP1_ALLOCA]] to i8*
    // O1: call void @llvm.lifetime.start.p0i8({{[^,]*}}, i8* %[[P]])
    // O1: br i1 {{[^,]+}}, label %[[IF_THEN:[^,]+]], label %[[IF_END:[^,]+]]
    //
    // O1: [[IF_THEN]]:
    // O1: %[[P:[^ ]+]] = bitcast %struct.S* %[[TMP1_ALLOCA]] to i8*
    // O1: call void @llvm.lifetime.end.p0i8({{[^,]*}}, i8* %[[P]])
    // O1: br label %[[DO_END:.*]]
    //
    // O1: [[IF_END]]:
    // O1: call void @foo_int(%struct.S* sret %[[TMP1_ALLOCA]],
    // O1: call void @llvm.memcpy
    // O1: %[[P:[^ ]+]] = bitcast %struct.S* %[[TMP1_ALLOCA]] to i8*
    // O1: call void @llvm.lifetime.end.p0i8({{[^,]*}}, i8* %[[P]])
    // O1: %[[P:[^ ]+]] = bitcast %struct.S* %[[TMP2_ALLOCA]] to i8*
    // O1: call void @llvm.lifetime.start.p0i8({{[^,]*}}, i8* %[[P]])
    // O1: call void @foo_int(%struct.S* sret %[[TMP2_ALLOCA]],
    // O1: call void @llvm.memcpy
    // O1: %[[P:[^ ]+]] = bitcast %struct.S* %[[TMP2_ALLOCA]] to i8*
    // O1: call void @llvm.lifetime.end.p0i8({{[^,]*}}, i8* %[[P]])
    // O1: br label %[[DO_COND:.*]]
    //
    // O1: [[DO_COND]]:
    // O1: br label %[[DO_BODY]]
    r = foo_int(({
      if (*j)
        break;
      i++;
    }));

    r = foo_int(i++);
   } while (1);
int bar_int(void) {
  return __real__(foo_int(2 - 3i));
}
void bar_int(void) {
  foo_int(2 - 3i);
}
Beispiel #5
0
main() {

    int i, n, m5, ma, mf;
    double a, b, h, x, f, err;
    double *c, *cint, *cder;

    a = 0.0;
    b = 5.0;
    h = (b-a)/10.0;
    n = 40;
    m5 = 5;
    ma = 10;
    mf = 15;

    c = dvector( 0, n-1 );
    cder = dvector( 0, n-1 );
    cint = dvector( 0, n-1 );


    printf( "\n\n\n  Test Chebyshev fitting.\n" );



    chebyshev_fit( a, b, c, n, one );
    chebyshev_deriv( a, b, c, cder, mf );
    chebyshev_integ( a, b, c, cint, mf );

    printf( "\n\n  Fit of f(x) = 1 from a = %3.1f to b = %3.1f with %d coefficients . . .", a, b, n );
    for ( i = 0; i < n/2; ++i ) printf( "\n  c[%2d] = %16.12f                c[%2d] = %16.12f", i, c[i], i+n/2, c[i+n/2] );

    printf( "\n\n  Evaluation of f(x) = 1 from a = %3.1f to b = %3.1f with %d coefficients . . .", a, b, m5 );
    x = a;
    while ( x <= b ) {
        f = chebyshev_eval( a, b, c, m5, x );
        err = f - one(x);
        printf( "\n  f(%3.1f) = %16.12f    error = %16.12f", x, f, err );
        x += h;
    }

    printf( "\n\n  Evaluation of f(x) = 1 from a = %3.1f to b = %3.1f with %d coefficients . . .", a, b, ma );
    x = a;
    while ( x <= b ) {
        f = chebyshev_eval( a, b, c, ma, x );
        err = f - one(x);
        printf( "\n  f(%3.1f) = %16.12f    error = %16.12f", x, f, err );
        x += h;
    }

    printf( "\n\n  Evaluation of derivative of f(x) from a = %3.1f to b = %3.1f with %d coefficients . . .", a, b, ma );
    x = a;
    while ( x <= b ) {
        f = chebyshev_eval( a, b, cder, ma, x );
        err = f - one_der(x);
        printf( "\n  f(%3.1f) = %16.12f    error = %16.12f", x, f, err );
        x += h;
    }

    printf( "\n\n  Evaluation of integral of f(x) from a = %3.1f to b = %3.1f with %d coefficients . . .", a, b, ma );
    x = a;
    while ( x <= b ) {
        f = chebyshev_eval( a, b, cint, ma, x );
        err = f - one_int(x);
        printf( "\n  f(%3.1f) = %16.12f    error = %16.12f", x, f, err );
        x += h;
    }



    chebyshev_fit( a, b, c, n, ex );
    chebyshev_deriv( a, b, c, cder, mf );
    chebyshev_integ( a, b, c, cint, mf );

    printf( "\n\n  Fit of f(x) = x from a = %3.1f to b = %3.1f with %d coefficients . . .", a, b, n );
    for ( i = 0; i < n/2; ++i ) printf( "\n  c[%2d] = %16.12f                c[%2d] = %16.12f", i, c[i], i+n/2, c[i+n/2] );

    printf( "\n\n  Evaluation of f(x) = x from a = %3.1f to b = %3.1f with %d coefficients . . .", a, b, m5 );
    x = a;
    while ( x <= b ) {
        f = chebyshev_eval( a, b, c, m5, x );
        err = f - ex(x);
        printf( "\n  f(%3.1f) = %16.12f    error = %16.12f", x, f, err );
        x += h;
    }

    printf( "\n\n  Evaluation of f(x) = x from a = %3.1f to b = %3.1f with %d coefficients . . .", a, b, ma );
    x = a;
    while ( x <= b ) {
        f = chebyshev_eval( a, b, c, ma, x );
        err = f - ex(x);
        printf( "\n  f(%3.1f) = %16.12f    error = %16.12f", x, f, err );
        x += h;
    }

    printf( "\n\n  Evaluation of derivative of f(x) from a = %3.1f to b = %3.1f with %d coefficients . . .", a, b, ma );
    x = a;
    while ( x <= b ) {
        f = chebyshev_eval( a, b, cder, ma, x );
        err = f - ex_der(x);
        printf( "\n  f(%3.1f) = %16.12f    error = %16.12f", x, f, err );
        x += h;
    }

    printf( "\n\n  Evaluation of integral of f(x) from a = %3.1f to b = %3.1f with %d coefficients . . .", a, b, ma );
    x = a;
    while ( x <= b ) {
        f = chebyshev_eval( a, b, cint, ma, x );
        err = f - ex_int(x);
        printf( "\n  f(%3.1f) = %16.12f    error = %16.12f", x, f, err );
        x += h;
    }



    chebyshev_fit( a, b, c, n, foo );
    chebyshev_deriv( a, b, c, cder, mf );
    chebyshev_integ( a, b, c, cint, n );

    printf( "\n\n  Fit of f(x) = (1 - x)exp(-x/2) from a = %3.1f to b = %3.1f with %d coefficients . . .", a, b, n );
    for ( i = 0; i < n/2; ++i ) printf( "\n  c[%2d] = %16.12f                c[%2d] = %16.12f", i, c[i], i+n/2, c[i+n/2] );

    printf( "\n\n  Fit of f'(x) = -(3 - x)exp(-x/2)/2 from a = %3.1f to b = %3.1f with %d coefficients . . .", a, b, n );
    for ( i = 0; i < n/2; ++i ) printf( "\n  cder[%2d] = %16.12f                cder[%2d] = %16.12f", i, cder[i], i+n/2, cder[i+n/2] );

    printf( "\n\n  Fit of F(x) = 2(1 + x)exp(-x/2) - 2 from a = %3.1f to b = %3.1f with %d coefficients . . .", a, b, n );
    for ( i = 0; i < n/2; ++i ) printf( "\n  cint[%2d] = %16.12f                cint[%2d] = %16.12f", i, cint[i], i+n/2, cint[i+n/2] );

    printf( "\n\n  Evaluation of f(x) = (1 - x)exp(-x/2) from a = %3.1f to b = %3.1f with %d coefficients . . .", a, b, m5 );
    x = a;
    while ( x <= b ) {
        f = chebyshev_eval( a, b, c, m5, x );
        err = f - foo(x);
        printf( "\n  f(%3.1f) = %16.12f    error = %16.12f", x, f, err );
        x += h;
    }

    printf( "\n\n  Evaluation of f(x) = (1 - x)exp(-x/2) from a = %3.1f to b = %3.1f with %d coefficients . . .", a, b, ma );
    x = a;
    while ( x <= b ) {
        f = chebyshev_eval( a, b, c, ma, x );
        err = f - foo(x);
        printf( "\n  f(%3.1f) = %16.12f    error = %16.12f", x, f, err );
        x += h;
    }

    printf( "\n\n  Evaluation of f(x) = (1 - x)exp(-x/2) from a = %3.1f to b = %3.1f with %d coefficients . . .", a, b, mf );
    x = a;
    while ( x <= b ) {
        f = chebyshev_eval( a, b, c, mf, x );
        err = f - foo(x);
        printf( "\n  f(%3.1f) = %16.12f    error = %16.12f", x, f, err );
        x += h;
    }

    printf( "\n\n  Evaluation of f'(x) = -(3 - x)exp(-x/2)/2 from a = %3.1f to b = %3.1f with %d coefficients . . .", a, b, mf );
    x = a;
    while ( x <= b ) {
        f = chebyshev_eval( a, b, cder, mf, x );
        err = f - foo_der(x);
        printf( "\n  f(%3.1f) = %16.12f    error = %16.12f", x, f, err );
        x += h;
    }

    printf( "\n\n  Evaluation F(x) = 2(1 + x)exp(-x/2) - 2 from a = %3.1f to b = %3.1f with %d coefficients . . .", a, b, mf );
    x = a;
    while ( x <= b ) {
        f = chebyshev_eval( a, b, cint, mf, x );
        err = f - foo_int(x);
        printf( "\n  f(%3.1f) = %16.12f    error = %16.12f", x, f, err );
        x += h;
    }




    printf( "\n\n" );


    free_dvector( cint, 0, n-1 );
    free_dvector( cder, 0, n-1 );
    free_dvector( c, 0, n-1 );
}