github.com/spotify/syslog-redirector-golang@v0.0.0-20140320174030-4859f03d829a/src/cmd/8c/machcap.c (about)

     1  // Inferno utils/8c/machcap.c
     2  // http://code.google.com/p/inferno-os/source/browse/utils/8c/machcap.c
     3  //
     4  //	Copyright © 1994-1999 Lucent Technologies Inc.  All rights reserved.
     5  //	Portions Copyright © 1995-1997 C H Forsyth (forsyth@terzarima.net)
     6  //	Portions Copyright © 1997-1999 Vita Nuova Limited
     7  //	Portions Copyright © 2000-2007 Vita Nuova Holdings Limited (www.vitanuova.com)
     8  //	Portions Copyright © 2004,2006 Bruce Ellis
     9  //	Portions Copyright © 2005-2007 C H Forsyth (forsyth@terzarima.net)
    10  //	Revisions Copyright © 2000-2007 Lucent Technologies Inc. and others
    11  //	Portions Copyright © 2009 The Go Authors.  All rights reserved.
    12  //
    13  // Permission is hereby granted, free of charge, to any person obtaining a copy
    14  // of this software and associated documentation files (the "Software"), to deal
    15  // in the Software without restriction, including without limitation the rights
    16  // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    17  // copies of the Software, and to permit persons to whom the Software is
    18  // furnished to do so, subject to the following conditions:
    19  //
    20  // The above copyright notice and this permission notice shall be included in
    21  // all copies or substantial portions of the Software.
    22  //
    23  // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    24  // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    25  // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
    26  // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    27  // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    28  // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    29  // THE SOFTWARE.
    30  
    31  #include "gc.h"
    32  
    33  int
    34  machcap(Node *n)
    35  {
    36  
    37  	if(n == Z)
    38  		return 1;	/* test */
    39  
    40  	switch(n->op) {
    41  	case OMUL:
    42  	case OLMUL:
    43  	case OASMUL:
    44  	case OASLMUL:
    45  		if(typechl[n->type->etype])
    46  			return 1;
    47  		if(typev[n->type->etype]) {
    48  				return 1;
    49  		}
    50  		break;
    51  
    52  	case OCOM:
    53  	case ONEG:
    54  	case OADD:
    55  	case OAND:
    56  	case OOR:
    57  	case OSUB:
    58  	case OXOR:
    59  	case OASHL:
    60  	case OLSHR:
    61  	case OASHR:
    62  		if(typechlv[n->left->type->etype])
    63  			return 1;
    64  		break;
    65  
    66  	case OCAST:
    67  		if(typev[n->type->etype]) {
    68  			if(typechlp[n->left->type->etype])
    69  				return 1;
    70  		}
    71  		else if(!typefd[n->type->etype]) {
    72  			if(typev[n->left->type->etype])
    73  				return 1;
    74  		}
    75  		break;
    76  
    77  	case OCOND:
    78  	case OCOMMA:
    79  	case OLIST:
    80  	case OANDAND:
    81  	case OOROR:
    82  	case ONOT:
    83  		return 1;
    84  
    85  	case OASADD:
    86  	case OASSUB:
    87  	case OASAND:
    88  	case OASOR:
    89  	case OASXOR:
    90  		return 1;
    91  
    92  	case OASASHL:
    93  	case OASASHR:
    94  	case OASLSHR:
    95  		return 1;
    96  
    97  	case OPOSTINC:
    98  	case OPOSTDEC:
    99  	case OPREINC:
   100  	case OPREDEC:
   101  		return 1;
   102  
   103  	case OEQ:
   104  	case ONE:
   105  	case OLE:
   106  	case OGT:
   107  	case OLT:
   108  	case OGE:
   109  	case OHI:
   110  	case OHS:
   111  	case OLO:
   112  	case OLS:
   113  		return 1;
   114  	}
   115  	return 0;
   116  }