//===---------------- PBQP.cpp --------- PBQP Solver ------------*- C++ -*-===////// The LLVM Compiler Infrastructure//// This file is distributed under the University of Illinois Open Source// License. See LICENSE.TXT for details.////===----------------------------------------------------------------------===////// Developed by: Bernhard Scholz// The University of Sydney// http://www.it.usyd.edu.au/~scholz//===----------------------------------------------------------------------===//#include"PBQP.h"#include"llvm/Config/alloca.h"#include<limits>#include<cassert>#include<cstring>namespacellvm{/************************************************************************** * Data Structures **************************************************************************//* edge of PBQP graph */typedefstructadjnode{structadjnode*prev,/* doubly chained list */*succ,*reverse;/* reverse edge */intadj;/* adj. node */PBQPMatrix*costs;/* cost matrix of edge */booltc_valid;/* flag whether following fields are valid */int*tc_safe_regs;/* safe registers */inttc_impact;/* impact */}adjnode;/* bucket node */typedefstructbucketnode{structbucketnode*prev;/* doubly chained list */structbucketnode*succ;intu;/* node */}bucketnode;/* data structure of partitioned boolean quadratic problem */structpbqp{intnum_nodes;/* number of nodes */intmax_deg;/* maximal degree of a node */boolsolved;/* flag that indicates whether PBQP has been solved yet */booloptimal;/* flag that indicates whether PBQP is optimal */PBQPNummin;boolchanged;/* flag whether graph has changed in simplification *//* node fields */PBQPVector**node_costs;/* cost vectors of nodes */int*node_deg;/* node degree of nodes */int*solution;/* solution for node */adjnode**adj_list;/* adj. list */bucketnode**bucket_ptr;/* bucket pointer of a node *//* node stack */int*stack;/* stack of nodes */intstack_ptr;/* stack pointer *//* bucket fields */bucketnode**bucket_list;/* bucket l