1/* Lambda matrix transformations. 2 Copyright (C) 2003, 2004 Free Software Foundation, Inc. 3 Contributed by Daniel Berlin <dberlin@dberlin.org>. 4 5This file is part of GCC. 6 7GCC is free software; you can redistribute it and/or modify it under 8the terms of the GNU General Public License as published by the Free 9Software Foundation; either version 2, or (at your option) any later 10version. 11 12GCC is distributed in the hope that it will be useful, but WITHOUT ANY 13WARRANTY; without even the implied warranty of MERCHANTABILITY or 14FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 15for more details. 16 17You should have received a copy of the GNU General Public License 18along with GCC; see the file COPYING. If not, write to the Free 19Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 2002110-1301, USA. */ 21 22#include "config.h" 23#include "system.h" 24#include "coretypes.h" 25#include "tm.h" 26#include "ggc.h" 27#include "tree.h" 28#include "target.h" 29#include "varray.h" 30#include "lambda.h" 31 32/* Allocate a new transformation matrix. */ 33 34lambda_trans_matrix 35lambda_trans_matrix_new (int colsize, int rowsize) 36{ 37 lambda_trans_matrix ret; 38 39 ret = ggc_alloc (sizeof (*ret)); 40 LTM_MATRIX (ret) = lambda_matrix_new (rowsize, colsize); 41 LTM_ROWSIZE (ret) = rowsize; 42 LTM_COLSIZE (ret) = colsize; 43 LTM_DENOMINATOR (ret) = 1; 44 return ret; 45} 46 47/* Return true if MAT is an identity matrix. */ 48 49bool 50lambda_trans_matrix_id_p (lambda_trans_matrix mat) 51{ 52 if (LTM_ROWSIZE (mat) != LTM_COLSIZE (mat)) 53 return false; 54 return lambda_matrix_id_p (LTM_MATRIX (mat), LTM_ROWSIZE (mat)); 55} 56 57 58/* Compute the inverse of the transformation matrix MAT. */ 59 60lambda_trans_matrix 61lambda_trans_matrix_inverse (lambda_trans_matrix mat) 62{ 63 lambda_trans_matrix inverse; 64 int determinant; 65 66 inverse = lambda_trans_matrix_new (LTM_ROWSIZE (mat), LTM_COLSIZE (mat)); 67 determinant = lambda_matrix_inverse (LTM_MATRIX (mat), LTM_MATRIX (inverse), 68 LTM_ROWSIZE (mat)); 69 LTM_DENOMINATOR (inverse) = determinant; 70 return inverse; 71} 72 73 74/* Print out a transformation matrix. */ 75 76void 77print_lambda_trans_matrix (FILE *outfile, lambda_trans_matrix mat) 78{ 79 print_lambda_matrix (outfile, LTM_MATRIX (mat), LTM_ROWSIZE (mat), 80 LTM_COLSIZE (mat)); 81} 82