Changeset e04ef3a for src/CodeGen


Ignore:
Timestamp:
Jun 14, 2016, 12:53:03 PM (9 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
c8c03683
Parents:
55ba7339
Message:

add gcc extension, first attempt, not done yet

Location:
src/CodeGen
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/CodeGen/CodeGenerator.cc

    r55ba7339 re04ef3a  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Rob Schluntz
    12 // Last Modified On : Fri May 06 16:01:00 2016
    13 // Update Count     : 255
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Thu Jun  9 13:21:00 2016
     13// Update Count     : 256
    1414//
    1515
     
    250250        //*** Expressions
    251251        void CodeGenerator::visit( ApplicationExpr *applicationExpr ) {
     252                extension( applicationExpr );
    252253                if ( VariableExpr *varExpr = dynamic_cast< VariableExpr* >( applicationExpr->get_function() ) ) {
    253254                        OperatorInfo opInfo;
     
    361362
    362363        void CodeGenerator::visit( UntypedExpr *untypedExpr ) {
     364                extension( untypedExpr );
    363365                if ( NameExpr *nameExpr = dynamic_cast< NameExpr* >( untypedExpr->get_function() ) ) {
    364366                        OperatorInfo opInfo;
     
    445447
    446448        void CodeGenerator::visit( NameExpr *nameExpr ) {
     449                extension( nameExpr );
    447450                OperatorInfo opInfo;
    448451                if ( operatorLookup( nameExpr->get_name(), opInfo ) ) {
     
    455458
    456459        void CodeGenerator::visit( AddressExpr *addressExpr ) {
     460                extension( addressExpr );
    457461                output << "(&";
    458462                // this hack makes sure that we don't convert "constant_zero" to "0" if we're taking its address
     
    466470
    467471        void CodeGenerator::visit( CastExpr *castExpr ) {
     472                extension( castExpr );
    468473                output << "(";
    469474                if ( castExpr->get_results().empty() ) {
     
    488493
    489494        void CodeGenerator::visit( MemberExpr *memberExpr ) {
     495                extension( memberExpr );
    490496                memberExpr->get_aggregate()->accept( *this );
    491497                output << "." << mangleName( memberExpr->get_member() );
     
    493499
    494500        void CodeGenerator::visit( VariableExpr *variableExpr ) {
     501                extension( variableExpr );
    495502                OperatorInfo opInfo;
    496503                if ( variableExpr->get_var()->get_linkage() == LinkageSpec::Intrinsic && operatorLookup( variableExpr->get_var()->get_name(), opInfo ) && opInfo.type == OT_CONSTANT ) {
     
    503510        void CodeGenerator::visit( ConstantExpr *constantExpr ) {
    504511                assert( constantExpr->get_constant() );
     512                extension( constantExpr );
    505513                constantExpr->get_constant()->accept( *this );
    506514        }
    507515
    508516        void CodeGenerator::visit( SizeofExpr *sizeofExpr ) {
     517                extension( sizeofExpr );
    509518                output << "sizeof(";
    510519                if ( sizeofExpr->get_isType() ) {
     
    517526
    518527        void CodeGenerator::visit( AlignofExpr *alignofExpr ) {
     528                extension( alignofExpr );
    519529                // use GCC extension to avoid bumping std to C11
    520530                output << "__alignof__(";
     
    532542
    533543        void CodeGenerator::visit( OffsetofExpr *offsetofExpr ) {
     544                extension( offsetofExpr );
    534545                // use GCC builtin
    535546                output << "__builtin_offsetof(";
     
    544555
    545556        void CodeGenerator::visit( LogicalExpr *logicalExpr ) {
     557                extension( logicalExpr );
    546558                output << "(";
    547559                logicalExpr->get_arg1()->accept( *this );
     
    556568
    557569        void CodeGenerator::visit( ConditionalExpr *conditionalExpr ) {
     570                extension( conditionalExpr );
    558571                output << "(";
    559572                conditionalExpr->get_arg1()->accept( *this );
     
    566579
    567580        void CodeGenerator::visit( CommaExpr *commaExpr ) {
     581                extension( commaExpr );
    568582                output << "(";
    569583                commaExpr->get_arg1()->accept( *this );
     
    578592
    579593        void CodeGenerator::visit( AsmExpr *asmExpr ) {
     594                extension( asmExpr );
    580595                if ( asmExpr->get_inout() ) {
    581596                        output << "[ ";
  • src/CodeGen/CodeGenerator.h

    r55ba7339 re04ef3a  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Mar  2 17:32:24 2016
    13 // Update Count     : 28
     12// Last Modified On : Thu Jun  9 13:15:58 2016
     13// Update Count     : 29
    1414//
    1515
     
    9494                        std::ostream& operator()(std::ostream & os);
    9595                };
     96
     97                void extension( Expression *expr ) {
     98                        if ( expr->get_extension() ) {
     99                                output << "__extension__ ";
     100                        } // if
     101                } // extension
    96102          private:
    97103
Note: See TracChangeset for help on using the changeset viewer.